本文整理汇总了Java中org.apache.http.HttpVersion.HTTP_1_0属性的典型用法代码示例。如果您正苦于以下问题:Java HttpVersion.HTTP_1_0属性的具体用法?Java HttpVersion.HTTP_1_0怎么用?Java HttpVersion.HTTP_1_0使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.apache.http.HttpVersion
的用法示例。
在下文中一共展示了HttpVersion.HTTP_1_0属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toProtocolVersion
private ProtocolVersion toProtocolVersion(String httpVersion) {
switch (httpVersion) {
case "HTTP/0.9":
case "0.9":
return HttpVersion.HTTP_0_9;
case "HTTP/1.0":
case "1.0":
return HttpVersion.HTTP_1_0;
case "HTTP/1.1":
case "1.1":
return HttpVersion.HTTP_1_1;
default:
throw new IllegalArgumentException("Invalid HTTP version: " + httpVersion);
}
}
示例2: responseToGetWithQueryFrom1_0OriginAndNoExpiresIsNotCached
@Test
public void responseToGetWithQueryFrom1_0OriginAndNoExpiresIsNotCached()
throws Exception {
final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(
new HttpGet("http://foo.example.com/bar?baz=quux"));
final HttpResponse resp2 = new BasicHttpResponse(HttpVersion.HTTP_1_0, HttpStatus.SC_OK, "OK");
resp2.setEntity(HttpTestUtils.makeBody(200));
resp2.setHeader("Content-Length","200");
resp2.setHeader("Date", DateUtils.formatDate(now));
backendExpectsAnyRequestAndReturn(resp2);
replayMocks();
impl.execute(route, req2, context, null);
verifyMocks();
}
示例3: responseToGetWithQueryFrom1_0OriginVia1_1ProxyAndNoExpiresIsNotCached
@Test
public void responseToGetWithQueryFrom1_0OriginVia1_1ProxyAndNoExpiresIsNotCached()
throws Exception {
final HttpRequestWrapper req2 = HttpRequestWrapper.wrap(
new HttpGet("http://foo.example.com/bar?baz=quux"));
final HttpResponse resp2 = new BasicHttpResponse(HttpVersion.HTTP_1_0, HttpStatus.SC_OK, "OK");
resp2.setEntity(HttpTestUtils.makeBody(200));
resp2.setHeader("Content-Length","200");
resp2.setHeader("Date", DateUtils.formatDate(now));
resp2.setHeader("Via","1.0 someproxy");
backendExpectsAnyRequestAndReturn(resp2);
replayMocks();
impl.execute(route, req2, context, null);
verifyMocks();
}
示例4: execute
void execute() throws Throwable {
requestVersion = HttpVersion.HTTP_1_0;
runTest(this);
requestVersion = HttpVersion.HTTP_1_1;
runTest(this);
executorService.shutdown();
}
示例5: upgrades1_0RequestTo1_1
@Test
public void upgrades1_0RequestTo1_1() throws Exception {
req = new BasicHttpRequest("GET", "/", HttpVersion.HTTP_1_0);
final HttpRequestWrapper wrapper = HttpRequestWrapper.wrap(req);
impl.makeRequestCompliant(wrapper);
assertEquals(HttpVersion.HTTP_1_1, wrapper.getProtocolVersion());
}
示例6: getsWithQueryParametersDirectlyFrom1_0OriginsAreNotCacheableEvenWithSetting
@Test
public void getsWithQueryParametersDirectlyFrom1_0OriginsAreNotCacheableEvenWithSetting() {
policy = new ResponseCachingPolicy(0, true, true, false);
request = new BasicHttpRequest("GET", "/foo?s=bar");
response = new BasicHttpResponse(HttpVersion.HTTP_1_0, HttpStatus.SC_OK, "OK");
Assert.assertFalse(policy.isResponseCacheable(request, response));
}
示例7: headsWithQueryParametersDirectlyFrom1_0OriginsAreNotCacheableEvenWithSetting
@Test
public void headsWithQueryParametersDirectlyFrom1_0OriginsAreNotCacheableEvenWithSetting() {
policy = new ResponseCachingPolicy(0, true, true, false);
request = new BasicHttpRequest("HEAD", "/foo?s=bar");
response = new BasicHttpResponse(HttpVersion.HTTP_1_0, HttpStatus.SC_OK, "OK");
Assert.assertFalse(policy.isResponseCacheable(request, response));
}
示例8: getsWithQueryParametersDirectlyFrom1_0OriginsAreCacheableWithExpires
@Test
public void getsWithQueryParametersDirectlyFrom1_0OriginsAreCacheableWithExpires() {
request = new BasicHttpRequest("GET", "/foo?s=bar");
response = new BasicHttpResponse(HttpVersion.HTTP_1_0, HttpStatus.SC_OK, "OK");
response.setHeader("Date", DateUtils.formatDate(now));
response.setHeader("Expires", DateUtils.formatDate(tenSecondsFromNow));
Assert.assertTrue(policy.isResponseCacheable(request, response));
}
示例9: headsWithQueryParametersDirectlyFrom1_0OriginsAreCacheableWithExpires
@Test
public void headsWithQueryParametersDirectlyFrom1_0OriginsAreCacheableWithExpires() {
policy = new ResponseCachingPolicy(0, true, false, false);
request = new BasicHttpRequest("HEAD", "/foo?s=bar");
response = new BasicHttpResponse(HttpVersion.HTTP_1_0, HttpStatus.SC_OK, "OK");
response.setHeader("Date", DateUtils.formatDate(now));
response.setHeader("Expires", DateUtils.formatDate(tenSecondsFromNow));
Assert.assertTrue(policy.isResponseCacheable(request, response));
}
示例10: getsWithQueryParametersDirectlyFrom1_0OriginsCanBeNotCacheableEvenWithExpires
@Test
public void getsWithQueryParametersDirectlyFrom1_0OriginsCanBeNotCacheableEvenWithExpires() {
policy = new ResponseCachingPolicy(0, true, true, false);
request = new BasicHttpRequest("GET", "/foo?s=bar");
response = new BasicHttpResponse(HttpVersion.HTTP_1_0, HttpStatus.SC_OK, "OK");
response.setHeader("Date", DateUtils.formatDate(now));
response.setHeader("Expires", DateUtils.formatDate(tenSecondsFromNow));
Assert.assertFalse(policy.isResponseCacheable(request, response));
}
示例11: headsWithQueryParametersDirectlyFrom1_0OriginsCanBeNotCacheableEvenWithExpires
@Test
public void headsWithQueryParametersDirectlyFrom1_0OriginsCanBeNotCacheableEvenWithExpires() {
policy = new ResponseCachingPolicy(0, true, true, false);
request = new BasicHttpRequest("HEAD", "/foo?s=bar");
response = new BasicHttpResponse(HttpVersion.HTTP_1_0, HttpStatus.SC_OK, "OK");
response.setHeader("Date", DateUtils.formatDate(now));
response.setHeader("Expires", DateUtils.formatDate(tenSecondsFromNow));
Assert.assertFalse(policy.isResponseCacheable(request, response));
}
示例12: getsWithQueryParametersFrom1_1OriginsVia1_0ProxiesAreCacheableWithExpires
@Test
public void getsWithQueryParametersFrom1_1OriginsVia1_0ProxiesAreCacheableWithExpires() {
request = new BasicHttpRequest("GET", "/foo?s=bar");
response = new BasicHttpResponse(HttpVersion.HTTP_1_0, HttpStatus.SC_OK, "OK");
response.setHeader("Date", DateUtils.formatDate(now));
response.setHeader("Expires", DateUtils.formatDate(tenSecondsFromNow));
response.setHeader("Via", "1.1 someproxy");
Assert.assertTrue(policy.isResponseCacheable(request, response));
}
示例13: headsWithQueryParametersFrom1_1OriginsVia1_0ProxiesAreCacheableWithExpires
@Test
public void headsWithQueryParametersFrom1_1OriginsVia1_0ProxiesAreCacheableWithExpires() {
policy = new ResponseCachingPolicy(0, true, false, false);
request = new BasicHttpRequest("HEAD", "/foo?s=bar");
response = new BasicHttpResponse(HttpVersion.HTTP_1_0, HttpStatus.SC_OK, "OK");
response.setHeader("Date", DateUtils.formatDate(now));
response.setHeader("Expires", DateUtils.formatDate(tenSecondsFromNow));
response.setHeader("Via", "1.1 someproxy");
Assert.assertTrue(policy.isResponseCacheable(request, response));
}
示例14: testRequestExpectContinueHTTP10
@Test
public void testRequestExpectContinueHTTP10() throws Exception {
final HttpContext context = new BasicHttpContext(null);
final RequestConfig config = RequestConfig.custom().setExpectContinueEnabled(true).build();
context.setAttribute(HttpClientContext.REQUEST_CONFIG, config);
final BasicHttpEntityEnclosingRequest request = new BasicHttpEntityEnclosingRequest(
"POST", "/", HttpVersion.HTTP_1_0);
final String s = "whatever";
final StringEntity entity = new StringEntity(s, "US-ASCII");
request.setEntity(entity);
final RequestExpectContinue interceptor = new RequestExpectContinue();
interceptor.process(request, context);
final Header header = request.getFirstHeader(HTTP.EXPECT_DIRECTIVE);
Assert.assertNull(header);
}
示例15: getsWithQueryParametersDirectlyFrom1_0OriginsAreNotCacheable
@Test
public void getsWithQueryParametersDirectlyFrom1_0OriginsAreNotCacheable() {
request = new BasicHttpRequest("GET", "/foo?s=bar");
response = new BasicHttpResponse(HttpVersion.HTTP_1_0, HttpStatus.SC_OK, "OK");
Assert.assertFalse(policy.isResponseCacheable(request, response));
}