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


Java HttpVersion.HTTP_1_0属性代码示例

本文整理汇总了Java中io.netty.handler.codec.http.HttpVersion.HTTP_1_0属性的典型用法代码示例。如果您正苦于以下问题:Java HttpVersion.HTTP_1_0属性的具体用法?Java HttpVersion.HTTP_1_0怎么用?Java HttpVersion.HTTP_1_0使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在io.netty.handler.codec.http.HttpVersion的用法示例。


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

示例1: build

public static HttpContext build(HttpRequestVisitor visitor) {
    HttpContext context = new HttpContext();
    context.remoteAddress = visitor.visitRemoteAddress();
    context.uri = visitor.visitURI();
    context.terms = visitor.visitTerms();
    context.requestMethod = visitor.visitHttpMethod();
    context.httpHeaders = visitor.visitHttpHeaders();
    context.httpParams = visitor.visitHttpParams();

    // TODO : if exclude GET or not ?
    //
    context.httpBody = visitor.visitHttpBody();

    if (visitor.visitHttpVersion() == HttpVersion.HTTP_1_1 &&
            HttpConstants.HEADER_CONNECTION_CLOSE.equals(context.httpHeaders.get(HttpConstants.HEADER_CONNECTION)))
        context.isKeepAlive = false;

    if (visitor.visitHttpVersion() == HttpVersion.HTTP_1_0 &&
            !HttpConstants.HEADER_CONNECTION_KEEPALIVE.equalsIgnoreCase(context.httpHeaders.get(HttpConstants.HEADER_CONNECTION)))
        context.isKeepAlive = false;

    return context;
}
 
开发者ID:gugemichael,项目名称:nesty,代码行数:23,代码来源:HttpContext.java

示例2: testBuildContent

@Test
public void testBuildContent()
    throws Exception {
  HttpRequest nettyRequest = new DefaultFullHttpRequest(HttpVersion.HTTP_1_0, HttpMethod.GET, "www.google.com");
  RecordedHttpRequestBuilder recordedHttpRequestBuilder = new RecordedHttpRequestBuilder(nettyRequest);

  String charset = "UTF-8";
  String str1 = "first content";
  HttpContent httpContent1 = new DefaultHttpContent(Unpooled.copiedBuffer(str1.getBytes(charset)));
  recordedHttpRequestBuilder.appendHttpContent(httpContent1);
  String str2 = "second content";
  HttpContent httpContent2 = new DefaultHttpContent(Unpooled.copiedBuffer(str2.getBytes(charset)));
  recordedHttpRequestBuilder.appendHttpContent(httpContent2);

  String lastStr = "Last chunk";
  HttpContent lastContent = new DefaultLastHttpContent(Unpooled.copiedBuffer(lastStr.getBytes(charset)));
  recordedHttpRequestBuilder.appendHttpContent(lastContent);

  RecordedHttpRequest recordedHttpRequest = recordedHttpRequestBuilder.build();
  Assert
      .assertEquals((str1 + str2 + lastStr).getBytes(charset), recordedHttpRequest.getHttpBody().getContent(charset));
}
 
开发者ID:linkedin,项目名称:flashback,代码行数:22,代码来源:RecordedHttpRequestBuilderTest.java

示例3: testBuild

@Test
public void testBuild()
    throws IOException {
  HttpResponse httpResponse = new DefaultFullHttpResponse(HttpVersion.HTTP_1_0, HttpResponseStatus.GATEWAY_TIMEOUT);
  RecordedHttpResponseBuilder recordedHttpResponseBuilder = new RecordedHttpResponseBuilder(httpResponse);

  String charset = "UTF-8";
  String str1 = "Hello world";
  HttpContent httpContent1 = new DefaultHttpContent(Unpooled.copiedBuffer(str1.getBytes(charset)));
  recordedHttpResponseBuilder.appendHttpContent(httpContent1);
  String str2 = "second content";
  HttpContent httpContent2 = new DefaultHttpContent(Unpooled.copiedBuffer(str2.getBytes(charset)));
  recordedHttpResponseBuilder.appendHttpContent(httpContent2);

  String lastStr = "Last chunk";
  HttpContent lastContent = new DefaultLastHttpContent(Unpooled.copiedBuffer(lastStr.getBytes(charset)));
  recordedHttpResponseBuilder.appendHttpContent(lastContent);
  RecordedHttpResponse recordedHttpResponse = recordedHttpResponseBuilder.build();
  Assert.assertEquals(recordedHttpResponse.getStatus(), HttpResponseStatus.GATEWAY_TIMEOUT.code());
  Assert.assertEquals((str1 + str2 + lastStr).getBytes(charset),
      recordedHttpResponse.getHttpBody().getContent(charset));
}
 
开发者ID:linkedin,项目名称:flashback,代码行数:22,代码来源:RecordedHttpResponseBuilderTest.java

示例4: protocolVersion

@Override
public HttpVersion protocolVersion() {
  if (version == HttpVer.HTTP_1_0) {
    return HttpVersion.HTTP_1_0;
  } else {
    return HttpVersion.HTTP_1_1;
  }
}
 
开发者ID:monkeyWie,项目名称:proxyee-down,代码行数:8,代码来源:HttpRequestInfo.java

示例5: testHttpsReq

@Test
public void testHttpsReq() {
	RequestKeyGenerator keyGen = new RequestKeyGenerator(
			s_appConfig);
	DefaultFullHttpRequest req1 = new DefaultFullHttpRequest(
			HttpVersion.HTTP_1_0, HttpMethod.GET, "/v1/s1");

	assertTrue(keyGen.generateKey(req1).startsWith("/v1/s1"));

	HttpHeaders.setHost(req1, "s.ebay.com");
	assertTrue(keyGen.generateKey(req1).startsWith(
			"https://s.ebay.com/v1/s1"));
}
 
开发者ID:eBay,项目名称:ServiceCOLDCache,代码行数:13,代码来源:RequestKeyGeneratorTest.java

示例6: testURIMatchOnly

@Test
public void testURIMatchOnly() throws IOException {
	AppConfiguration appConfig = new AppConfiguration(new ConfigLoader(),
			"./src/test/resources/testuserconfig.json");
	appConfig.init();
	RequestKeyGenerator keyGen = new RequestKeyGenerator(appConfig);

	ByteBuf buffer = UnpooledByteBufAllocator.DEFAULT.buffer();
	buffer.writeBytes("{\"fromDate\":1464251112185,\"toDate\":1464337512185}"
			.getBytes());
	DefaultFullHttpRequest req1 = new DefaultFullHttpRequest(
			HttpVersion.HTTP_1_0, HttpMethod.GET,
			"http://test.ebay.com/v1/s1", buffer);

	String key1 = keyGen.generateKey(req1);

	buffer = UnpooledByteBufAllocator.DEFAULT.buffer();
	buffer.writeBytes("{\"fromDate\":1464251113750,\"toDate\":1464337513750}"
			.getBytes());
	DefaultFullHttpRequest req2 = new DefaultFullHttpRequest(
			HttpVersion.HTTP_1_0, HttpMethod.GET,
			"http://test.ebay.com/v1/s1", buffer);

	String key2 = keyGen.generateKey(req2);
	assertEquals(key1, key2);

	HttpHeaders.setContentLength(req2, 758);
	key2 = keyGen.generateKey(req2);
	assertEquals(key1, key2);

	appConfig.put("uriMatchOnly", null);
	keyGen = new RequestKeyGenerator(appConfig);
	key1 = keyGen.generateKey(req1);
	key2 = keyGen.generateKey(req2);

	assertNotEquals(key1, key2);
}
 
开发者ID:eBay,项目名称:ServiceCOLDCache,代码行数:37,代码来源:RequestKeyGeneratorTest.java

示例7: fromVersion

private HttpVersion fromVersion(Message.Version version) {
  switch (version) {
    case HTTP_1_0: return HttpVersion.HTTP_1_0;
    case HTTP_1_1: return HttpVersion.HTTP_1_1;
    default: return HttpVersion.HTTP_1_1;
  }
}
 
开发者ID:RestNEXT,项目名称:restnext,代码行数:7,代码来源:ServerHandler.java

示例8: createTestRequest

private Request createTestRequest()
{
    Request r = new Request(new DefaultFullHttpRequest(HttpVersion.HTTP_1_0, HttpMethod.GET, "/test/path/here"), new RouteResolver(null));
    r.addHeader("testHeader_1", "test1");
    r.addHeader("testHeader_1", "test2");
    r.addHeader("testHeader_1", "test3");
    r.addHeader("testHeader_2", "test4");
    return r;
}
 
开发者ID:PearsonEducation,项目名称:Docussandra,代码行数:9,代码来源:SecurityPluginPreproccessorTest.java

示例9: testBuildHttpMethod

@Test
public void testBuildHttpMethod() {
  HttpRequest nettyRequest =
      new DefaultFullHttpRequest(HttpVersion.HTTP_1_0, HttpMethod.GET, "http://www.google.com");
  RecordedHttpRequestBuilder recordedHttpRequestBuilder = new RecordedHttpRequestBuilder(nettyRequest);
  RecordedHttpRequest recordedHttpRequest = recordedHttpRequestBuilder.build();
  Assert.assertEquals(recordedHttpRequest.getMethod(), HttpMethod.GET.toString());
}
 
开发者ID:linkedin,项目名称:flashback,代码行数:8,代码来源:RecordedHttpRequestBuilderTest.java

示例10: testBuildAbsoluteUri

@Test
public void testBuildAbsoluteUri() {
  String uri = "http://www.google.com";
  HttpRequest nettyRequest = new DefaultFullHttpRequest(HttpVersion.HTTP_1_0, HttpMethod.GET, uri);
  RecordedHttpRequestBuilder recordedHttpRequestBuilder = new RecordedHttpRequestBuilder(nettyRequest);
  RecordedHttpRequest recordedHttpRequest = recordedHttpRequestBuilder.build();
  Assert.assertEquals(recordedHttpRequest.getUri().toString(), uri);
}
 
开发者ID:linkedin,项目名称:flashback,代码行数:8,代码来源:RecordedHttpRequestBuilderTest.java

示例11: testBuildRelativeUri

@Test
public void testBuildRelativeUri() {
  String uri = "finance";
  HttpRequest nettyRequest = new DefaultFullHttpRequest(HttpVersion.HTTP_1_0, HttpMethod.GET, uri);
  nettyRequest.headers().set(HttpHeaders.Names.HOST, "www.google.com/");
  RecordedHttpRequestBuilder recordedHttpRequestBuilder = new RecordedHttpRequestBuilder(nettyRequest);
  RecordedHttpRequest recordedHttpRequest = recordedHttpRequestBuilder.build();
  Assert.assertEquals(recordedHttpRequest.getUri().toString(), "https://www.google.com/finance");
}
 
开发者ID:linkedin,项目名称:flashback,代码行数:9,代码来源:RecordedHttpRequestBuilderTest.java

示例12: testBuildWithUnsupportedUri

@Test(expectedExceptions = IllegalStateException.class)
public void testBuildWithUnsupportedUri() {
  String uri = "http://example.com/file[/].html";
  HttpRequest nettyRequest = new DefaultFullHttpRequest(HttpVersion.HTTP_1_0, HttpMethod.GET, uri);
  RecordedHttpRequestBuilder recordedHttpRequestBuilder = new RecordedHttpRequestBuilder(nettyRequest);
  recordedHttpRequestBuilder.build();
}
 
开发者ID:linkedin,项目名称:flashback,代码行数:7,代码来源:RecordedHttpRequestBuilderTest.java

示例13: testBuildWithUriTwoLegs

@Test
public void testBuildWithUriTwoLegs() {
  HttpRequest nettyRequest1 = new DefaultFullHttpRequest(HttpVersion.HTTP_1_0, HttpMethod.GET, "finance");
  RecordedHttpRequestBuilder recordedHttpRequestBuilder = new RecordedHttpRequestBuilder(nettyRequest1);
  HttpRequest nettyRequest2 = new DefaultFullHttpRequest(HttpVersion.HTTP_1_0, HttpMethod.GET, "google.com");
  nettyRequest2.headers().set(HttpHeaders.Names.HOST, "www.google.com/");
  recordedHttpRequestBuilder.addHeaders(nettyRequest2);
  RecordedHttpRequest recordedHttpRequest = recordedHttpRequestBuilder.build();
  Assert.assertEquals(recordedHttpRequest.getUri().toString(), "https://www.google.com/finance");
}
 
开发者ID:linkedin,项目名称:flashback,代码行数:10,代码来源:RecordedHttpRequestBuilderTest.java

示例14: testBuildWithUriTwoLegsIllegalUri

@Test(expectedExceptions = IllegalStateException.class)
public void testBuildWithUriTwoLegsIllegalUri() {
  HttpRequest nettyRequest1 = new DefaultFullHttpRequest(HttpVersion.HTTP_1_0, HttpMethod.GET, "file[/].html");
  RecordedHttpRequestBuilder recordedHttpRequestBuilder = new RecordedHttpRequestBuilder(nettyRequest1);
  HttpRequest nettyRequest2 = new DefaultFullHttpRequest(HttpVersion.HTTP_1_0, HttpMethod.GET, "google.com");
  nettyRequest2.headers().set(HttpHeaders.Names.HOST, "www.google.com/");
  recordedHttpRequestBuilder.addHeaders(nettyRequest2);
  recordedHttpRequestBuilder.build();
}
 
开发者ID:linkedin,项目名称:flashback,代码行数:9,代码来源:RecordedHttpRequestBuilderTest.java


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