本文整理匯總了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");
}
示例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));
}
示例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));
}
示例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));
}
示例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));
}
示例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));
}
示例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));
}
示例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);
}