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


Java BasicHttpResponse.setHeader方法代码示例

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


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

示例1: setup

import org.apache.http.message.BasicHttpResponse; //导入方法依赖的package包/类
@Before
public void setup() {
  response = new BasicHttpResponse(new ProtocolVersion("HTTP", 2, 0), 200, "OK");
  response.setHeader(HttpHeaders.CONTENT_LENGTH, String.valueOf(123));

  mockDelegate = mock(TraceHttpResponseInterceptor.class);
  responseInterceptor = new TraceResponseInterceptor(mockDelegate);
}
 
开发者ID:GoogleCloudPlatform,项目名称:cloud-trace-java-instrumentation,代码行数:9,代码来源:TraceResponseInterceptorTest.java

示例2: setUp

import org.apache.http.message.BasicHttpResponse; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
    now = new Date();
    sixSecondsAgo = new Date(now.getTime() - 6 * 1000L);
    tenSecondsFromNow = new Date(now.getTime() + 10 * 1000L);

    policy = new ResponseCachingPolicy(0, true, false, false);
    request = new BasicHttpRequest("GET","/",HTTP_1_1);
    response = new BasicHttpResponse(
            new BasicStatusLine(HTTP_1_1, HttpStatus.SC_OK, ""));
    response.setHeader("Date", DateUtils.formatDate(new Date()));
    response.setHeader("Content-Length", "0");
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:14,代码来源:TestResponseCachingPolicy.java

示例3: getsWithQueryParametersDirectlyFrom1_0OriginsAreCacheableWithExpires

import org.apache.http.message.BasicHttpResponse; //导入方法依赖的package包/类
@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));
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:9,代码来源:TestResponseCachingPolicy.java

示例4: headsWithQueryParametersDirectlyFrom1_0OriginsAreCacheableWithExpires

import org.apache.http.message.BasicHttpResponse; //导入方法依赖的package包/类
@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));
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:10,代码来源:TestResponseCachingPolicy.java

示例5: getsWithQueryParametersDirectlyFrom1_0OriginsCanBeNotCacheableEvenWithExpires

import org.apache.http.message.BasicHttpResponse; //导入方法依赖的package包/类
@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));
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:10,代码来源:TestResponseCachingPolicy.java

示例6: headsWithQueryParametersDirectlyFrom1_0OriginsCanBeNotCacheableEvenWithExpires

import org.apache.http.message.BasicHttpResponse; //导入方法依赖的package包/类
@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));
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:10,代码来源:TestResponseCachingPolicy.java

示例7: getsWithQueryParametersFrom1_1OriginsVia1_0ProxiesAreCacheableWithExpires

import org.apache.http.message.BasicHttpResponse; //导入方法依赖的package包/类
@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));
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:10,代码来源:TestResponseCachingPolicy.java

示例8: headsWithQueryParametersFrom1_1OriginsVia1_0ProxiesAreCacheableWithExpires

import org.apache.http.message.BasicHttpResponse; //导入方法依赖的package包/类
@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));
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:11,代码来源:TestResponseCachingPolicy.java

示例9: doesNotFlushEntryForUnsuccessfulResponse

import org.apache.http.message.BasicHttpResponse; //导入方法依赖的package包/类
@Test
public void doesNotFlushEntryForUnsuccessfulResponse()
        throws Exception {
    response = new BasicHttpResponse(HttpVersion.HTTP_1_1, HttpStatus.SC_BAD_REQUEST, "Bad Request");
    response.setHeader("ETag","\"new-etag\"");
    response.setHeader("Date", DateUtils.formatDate(now));
    final String theURI = "http://foo.example.com:80/bar";
    response.setHeader("Content-Location", theURI);

    impl.flushInvalidatedCacheEntries(host, request, response);

    verifyNoMoreInteractions(mockStorage);
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:14,代码来源:TestCacheInvalidator.java


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