当前位置: 首页>>代码示例>>Java>>正文


Java MetaData类代码示例

本文整理汇总了Java中org.eclipse.jetty.http.MetaData的典型用法代码示例。如果您正苦于以下问题:Java MetaData类的具体用法?Java MetaData怎么用?Java MetaData使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


MetaData类属于org.eclipse.jetty.http包,在下文中一共展示了MetaData类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setup

import org.eclipse.jetty.http.MetaData; //导入依赖的package包/类
@Before
public void setup() throws MalformedURLException {
	TestJMeterUtils.createJmeterEnv();
	JMeterUtils.setProperty("HTTPResponse.parsers", "htmlParser");
	JMeterUtils.setProperty("htmlParser.className","org.apache.jmeter.protocol.http.parser.LagartoBasedHtmlParser");
	JMeterUtils.setProperty("htmlParser.types","text/html application/xhtml+xml application/xml text/xml");
	url = new URL("http://www.tenfieldigital.com.uy");
	http2Connection = Mockito.mock(HTTP2Connection.class);
	stream = Mockito.mock(Stream.class);
	pushPromisFrame = Mockito.mock(PushPromiseFrame.class);
	headersFrame = Mockito.mock(HeadersFrame.class);
	responseMetadata = Mockito.mock(MetaData.Response.class);
	callback = Mockito.mock(Callback.class);
	dataFrame = Mockito.mock(DataFrame.class);
	
}
 
开发者ID:Blazemeter,项目名称:jmeter-bzm-plugins,代码行数:17,代码来源:HTTP2StreamHandlerTest.java

示例2: toRequestMetadata

import org.eclipse.jetty.http.MetaData; //导入依赖的package包/类
private static MetaData.Request toRequestMetadata(ServiceRequestContext ctx, AggregatedHttpMessage aReq) {
    // Construct the HttpURI
    final StringBuilder uriBuf = new StringBuilder();
    final HttpHeaders aHeaders = aReq.headers();

    uriBuf.append(ctx.sessionProtocol().isTls() ? "https" : "http");
    uriBuf.append("://");
    uriBuf.append(aHeaders.authority());
    uriBuf.append(aHeaders.path());

    final HttpURI uri = new HttpURI(uriBuf.toString());
    uri.setPath(ctx.mappedPath());

    // Convert HttpHeaders to HttpFields
    final HttpFields jHeaders = new HttpFields(aHeaders.size());
    aHeaders.forEach(e -> {
        final AsciiString key = e.getKey();
        if (!key.isEmpty() && key.byteAt(0) != ':') {
            jHeaders.add(key.toString(), e.getValue());
        }
    });

    return new MetaData.Request(
            aHeaders.method().name(), uri, HttpVersion.HTTP_1_1, jHeaders, aReq.content().length());
}
 
开发者ID:line,项目名称:armeria,代码行数:26,代码来源:JettyService.java

示例3: runRequest

import org.eclipse.jetty.http.MetaData; //导入依赖的package包/类
/**
 * Fire one request at the security handler (and by extension to the AuthServlet behind it).
 *
 * @param path The path to hit.
 * @param request The request object to use.
 * @param response The response object to use. Must be created by Mockito.mock()
 * @return Any data written to response.getWriter()
 * @throws IOException
 * @throws ServletException
 */
private String runRequest(String path, Request request, Response response)
    throws IOException, ServletException {
  //request.setMethod(/*HttpMethod.GET,*/ "GET");
  HttpURI uri  =new HttpURI("http", SERVER_NAME,9999, path);
  HttpFields httpf = new HttpFields();
  MetaData.Request metadata = new MetaData.Request("GET", uri, HttpVersion.HTTP_2, httpf);
  request.setMetaData(metadata);

  // request.setServerName(SERVER_NAME);
 // request.setAuthority(SERVER_NAME,9999);
 //// request.setPathInfo(path);
 //// request.setURIPathQuery(path);
  request.setDispatcherType(DispatcherType.REQUEST);
  doReturn(response).when(request).getResponse();

  ByteArrayOutputStream output = new ByteArrayOutputStream();
  try (PrintWriter writer = new PrintWriter(output)) {
    when(response.getWriter()).thenReturn(writer);
    securityHandler.handle(path, request, request, response);
  }
  return new String(output.toByteArray());
}
 
开发者ID:GoogleCloudPlatform,项目名称:appengine-java-vm-runtime,代码行数:33,代码来源:AppEngineAuthenticationTest.java

示例4: runRequest2

import org.eclipse.jetty.http.MetaData; //导入依赖的package包/类
private String runRequest2(String path, Request request, Response response)
     throws IOException, ServletException {
   //request.setMethod(/*HttpMethod.GET,*/ "GET");
   HttpURI uri  =new HttpURI("http", SERVER_NAME,9999, path);
   HttpFields httpf = new HttpFields();
   MetaData.Request metadata = new MetaData.Request("GET", uri, HttpVersion.HTTP_2, httpf);
//   request.setMetaData(metadata);

   // request.setServerName(SERVER_NAME);
  // request.setAuthority(SERVER_NAME,9999);
  //// request.setPathInfo(path);
  //// request.setURIPathQuery(path);
   request.setDispatcherType(DispatcherType.REQUEST);
   doReturn(response).when(request).getResponse();

   ByteArrayOutputStream output = new ByteArrayOutputStream();
   try (PrintWriter writer = new PrintWriter(output)) {
     when(response.getWriter()).thenReturn(writer);
     securityHandler.handle(path, request, request, response);
   }
   return new String(output.toByteArray());
 }
 
开发者ID:GoogleCloudPlatform,项目名称:appengine-java-vm-runtime,代码行数:23,代码来源:AppEngineAuthenticationTest.java

示例5: testUserRequired_NoUser

import org.eclipse.jetty.http.MetaData; //导入依赖的package包/类
public void testUserRequired_NoUser() throws Exception {
  String path = "/user/blah";
  Request request = spy(new Request(null, null));
  //request.setServerPort(9999);
      HttpURI uri  =new HttpURI("http", SERVER_NAME,9999, path);
  HttpFields httpf = new HttpFields();
  MetaData.Request metadata = new MetaData.Request("GET", uri, HttpVersion.HTTP_2, httpf);
  request.setMetaData(metadata);
 // request.setAuthority(SERVER_NAME,9999);
  Response response = mock(Response.class);
  String output = runRequest(path, request, response);
  // Verify that the servlet never was run (there is no output).
  assertEquals("", output);
  // Verify that the request was redirected to the login url.
  String loginUrl = UserServiceFactory.getUserService()
      .createLoginURL(String.format("http://%s%s", SERVER_NAME + ":9999", path));
  verify(response).sendRedirect(loginUrl);
}
 
开发者ID:GoogleCloudPlatform,项目名称:appengine-java-vm-runtime,代码行数:19,代码来源:AppEngineAuthenticationTest.java

示例6: testUserRequired_PreserveQueryParams

import org.eclipse.jetty.http.MetaData; //导入依赖的package包/类
public void testUserRequired_PreserveQueryParams() throws Exception {
  String path = "/user/blah";
  
  Request request = new Request(null, null);
  // request.setServerPort(9999);
      HttpURI uri  =new HttpURI("http", SERVER_NAME,9999, path,"foo=baqr","foo=bar","foo=barff");
  HttpFields httpf = new HttpFields();
  MetaData.Request metadata = new MetaData.Request("GET", uri, HttpVersion.HTTP_2, httpf);
  request.setMetaData(metadata);
  MultiMap<String> queryParameters = new MultiMap<> ();
  queryParameters.add("ffo", "bar");
  request.setQueryParameters(queryParameters);
      request = spy(request);

 /// request.setAuthority(SERVER_NAME,9999);
  request.setQueryString("foo=bar");
  Response response = mock(Response.class);
  String output = runRequest2(path, request, response);
  // Verify that the servlet never was run (there is no output).
  assertEquals("", output);
  // Verify that the request was redirected to the login url.
  String loginUrl = UserServiceFactory.getUserService()
      .createLoginURL(String.format("http://%s%s?foo=bar", SERVER_NAME + ":9999", path));
  verify(response).sendRedirect(loginUrl);
}
 
开发者ID:GoogleCloudPlatform,项目名称:appengine-java-vm-runtime,代码行数:26,代码来源:AppEngineAuthenticationTest.java

示例7: testAdminRequired_NoUser

import org.eclipse.jetty.http.MetaData; //导入依赖的package包/类
public void testAdminRequired_NoUser() throws Exception {
  String path = "/admin/blah";
  Request request = spy(new Request(null, null));
  //request.setServerPort(9999);
  HttpURI uri  =new HttpURI("http", SERVER_NAME,9999, path);
  HttpFields httpf = new HttpFields();
  MetaData.Request metadata = new MetaData.Request("GET", uri, HttpVersion.HTTP_2, httpf);
  request.setMetaData(metadata);
//  request.setAuthority(SERVER_NAME,9999);
  Response response = mock(Response.class);
  String output = runRequest(path, request, response);
  // Verify that the servlet never was run (there is no output).
  assertEquals("", output);
  // Verify that the request was redirected to the login url.
  String loginUrl = UserServiceFactory.getUserService()
      .createLoginURL(String.format("http://%s%s", SERVER_NAME + ":9999", path));
  verify(response).sendRedirect(loginUrl);
}
 
开发者ID:GoogleCloudPlatform,项目名称:appengine-java-vm-runtime,代码行数:19,代码来源:AppEngineAuthenticationTest.java

示例8: performHttpRequestReceivePush

import org.eclipse.jetty.http.MetaData; //导入依赖的package包/类
/**
 * Perform an http request and wait for a possibly incoming push promise.
 *
 * @param host           the hostname
 * @param port           the port
 * @param path           the request path
 * @param sessionPromise the session promise object
 * @param phaser         the phaser
 * @throws Exception may occur when client is started or stopped
 */
public void performHttpRequestReceivePush(
    String host, int port, String path,
    FuturePromise<Session> sessionPromise, Phaser phaser)
    throws Exception {

  http2Client.addBean(sslContextFactory);
  http2Client.start();

  http2Client.connect(sslContextFactory, new InetSocketAddress(host, port),
      new ServerSessionListener.Adapter(), sessionPromise);
  Session session = sessionPromise.get(5, TimeUnit.SECONDS);

  HttpFields requestFields = new HttpFields();
  requestFields.put("User-Agent", http2Client
      .getClass()
      .getName() + "/" + Jetty.VERSION);
  MetaData.Request metaData =
      new MetaData.Request("GET", new HttpURI("https://" + host + ":" + port + path),
          HttpVersion.HTTP_2, requestFields);
  HeadersFrame headersFrame = new HeadersFrame(metaData, null, true);
  session.newStream(headersFrame, new Promise.Adapter<>(), new StreamListener(phaser));

  phaser.awaitAdvanceInterruptibly(phaser.arrive(), 5, TimeUnit.SECONDS);

  http2Client.stop();
}
 
开发者ID:janweinschenker,项目名称:servlet4-demo,代码行数:37,代码来源:JettyClientDemo.java

示例9: toResponseHeaders

import org.eclipse.jetty.http.MetaData; //导入依赖的package包/类
private static HttpHeaders toResponseHeaders(ArmeriaHttpTransport transport) {
    final MetaData.Response info = transport.info;
    if (info == null) {
        throw new IllegalStateException("response metadata unavailable");
    }

    final HttpHeaders headers = HttpHeaders.of(HttpStatus.valueOf(info.getStatus()));
    info.getFields().forEach(e -> headers.add(HttpHeaderNames.of(e.getName()), e.getValue()));

    if (transport.method != HttpMethod.HEAD) {
        headers.setLong(HttpHeaderNames.CONTENT_LENGTH, transport.contentLength);
    }

    return headers;
}
 
开发者ID:line,项目名称:armeria,代码行数:16,代码来源:JettyService.java

示例10: send

import org.eclipse.jetty.http.MetaData; //导入依赖的package包/类
@Override
public void send(MetaData.Response info, boolean head,
                 ByteBuffer content, boolean lastContent, Callback callback) {

    if (info != null) {
        this.info = info;
    }

    final int length = content.remaining();
    if (length == 0) {
        callback.succeeded();
        return;
    }

    if (content.hasArray()) {
        final int from = content.arrayOffset() + content.position();
        out.add(HttpData.of(Arrays.copyOfRange(content.array(), from, from + length)));
        content.position(content.position() + length);
    } else {
        final byte[] data = new byte[length];
        content.get(data);
        out.add(HttpData.of(data));
    }

    contentLength += length;
    callback.succeeded();
}
 
开发者ID:line,项目名称:armeria,代码行数:28,代码来源:JettyService.java

示例11: onHeaders

import org.eclipse.jetty.http.MetaData; //导入依赖的package包/类
@Override
public void onHeaders(Stream stream, HeadersFrame frame) {

	MetaData.Response responseMetadata = ((MetaData.Response) frame.getMetaData());
	// set status line - header[0] is not the status line...
	String header = responseMetadata.getHttpVersion() + " " + Integer.toString(responseMetadata.getStatus()) + "\n";
	result.setResponseCode(Integer.toString(responseMetadata.getStatus()));
	HttpFields hdrs = new HttpFields();
	for (HttpField h : frame.getMetaData().getFields()) {
		header = header + h.getName() + ": " + h.getValue() + "\n";
		switch (h.getName()) {
		case HTTPConstants.HEADER_CONTENT_TYPE:// TODO adaptar para traducir
												// gzip, etc
		case "content-type":
			result.setContentType(h.getValue());
			result.setEncodingAndType(h.getValue());
			break;
		case HTTPConstants.HEADER_CONTENT_ENCODING:
			result.setDataEncoding(h.getValue());
			break;
		}
		hdrs.add(h);
	}
	header = header + "\n";
	result.setResponseHeaders(header);
	result.setHeadersSize(header.length());
	result.setBytes(result.getBytesAsLong() + result.getHeadersSize()); // add
																		// size
																		// bytes
																		// of
																		// the
																		// header
																		// response
	result.setHttpFieldsResponse(hdrs);
	if (frame.isEndStream()) {
		result.sampleEnd();
		result.setPendingResponse(false);
		completedFuture.complete(null);

	}
	if (!result.isPendingResponse()) {
		// the sample has failed for another reason (eg. timeout)
		result.setResponseHeaders("");
	}
}
 
开发者ID:Blazemeter,项目名称:jmeter-bzm-plugins,代码行数:46,代码来源:HTTP2StreamHandler.java

示例12: newResponseMetaData

import org.eclipse.jetty.http.MetaData; //导入依赖的package包/类
protected MetaData.Response newResponseMetaData()
{
    return new MetaData.Response(_channel.getRequest().getHttpVersion(), getStatus(), getReason(), _fields, getLongContentLength());
}
 
开发者ID:jmfgdev,项目名称:gitplex-mit,代码行数:5,代码来源:Response.java

示例13: main

import org.eclipse.jetty.http.MetaData; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
    long startTime = System.nanoTime();

    // Create and start HTTP2Client.
    HTTP2Client client = new HTTP2Client();
    SslContextFactory sslContextFactory = new SslContextFactory(true);
    client.addBean(sslContextFactory);
    client.start();

    // Connect to host.
    String host = "localhost";
    int port = 8443;

    FuturePromise<Session> sessionPromise = new FuturePromise<>();
    client.connect(sslContextFactory, new InetSocketAddress(host, port), new ServerSessionListener.Adapter(), sessionPromise);

    // Obtain the client Session object.
    Session session = sessionPromise.get(5, TimeUnit.SECONDS);

    // Prepare the HTTP request headers.
    HttpFields requestFields = new HttpFields();
    requestFields.put("User-Agent", client.getClass().getName() + "/" + Jetty.VERSION);
    // Prepare the HTTP request object.
    MetaData.Request request = new MetaData.Request("GET", new HttpURI("https://" + host + ":" + port + "/"), HttpVersion.HTTP_2, requestFields);
    // Create the HTTP/2 HEADERS frame representing the HTTP request.
    HeadersFrame headersFrame = new HeadersFrame(request, null, true);

    // Prepare the listener to receive the HTTP response frames.
    Stream.Listener responseListener = new Stream.Listener.Adapter()
    {
        @Override
        public void onData(Stream stream, DataFrame frame, Callback callback)
        {
            byte[] bytes = new byte[frame.getData().remaining()];
            frame.getData().get(bytes);
            int duration = (int) TimeUnit.NANOSECONDS.toSeconds(System.nanoTime() - startTime);
            System.out.println("After " + duration + " seconds: " + new String(bytes));
            callback.succeeded();
        }
    };

    session.newStream(headersFrame, new FuturePromise<>(), responseListener);
    session.newStream(headersFrame, new FuturePromise<>(), responseListener);
    session.newStream(headersFrame, new FuturePromise<>(), responseListener);

    Thread.sleep(TimeUnit.SECONDS.toMillis(20));

    client.stop();
}
 
开发者ID:fstab,项目名称:http2-examples,代码行数:50,代码来源:JettyClientExample.java

示例14: push

import org.eclipse.jetty.http.MetaData; //导入依赖的package包/类
@Override
public void push(MetaData.Request request) {}
 
开发者ID:line,项目名称:armeria,代码行数:3,代码来源:JettyService.java

示例15: getCommittedMetaData

import org.eclipse.jetty.http.MetaData; //导入依赖的package包/类
/** Get the MetaData.Response committed for this response.
 * This may differ from the meta data in this response for 
 * exceptional responses (eg 4xx and 5xx responses generated
 * by the container) and the committedMetaData should be used 
 * for logging purposes.
 * @return The committed MetaData or a {@link #newResponseMetaData()}
 * if not yet committed.
 */
public MetaData.Response getCommittedMetaData()
{
    MetaData.Response meta = _channel.getCommittedMetaData();
    if (meta==null)
        return newResponseMetaData();
    return meta;
}
 
开发者ID:jmfgdev,项目名称:gitplex-mit,代码行数:16,代码来源:Response.java


注:本文中的org.eclipse.jetty.http.MetaData类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。