本文整理匯總了Java中org.apache.http.HttpResponseInterceptor.process方法的典型用法代碼示例。如果您正苦於以下問題:Java HttpResponseInterceptor.process方法的具體用法?Java HttpResponseInterceptor.process怎麽用?Java HttpResponseInterceptor.process使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.http.HttpResponseInterceptor
的用法示例。
在下文中一共展示了HttpResponseInterceptor.process方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testContentEncodingRequestParameter
import org.apache.http.HttpResponseInterceptor; //導入方法依賴的package包/類
@Test
public void testContentEncodingRequestParameter() throws Exception {
final HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
final StringEntity original = new StringEntity("encoded stuff");
original.setContentEncoding("GZip");
response.setEntity(original);
final RequestConfig config = RequestConfig.custom()
.setDecompressionEnabled(false)
.build();
final HttpContext context = new BasicHttpContext();
context.setAttribute(HttpClientContext.REQUEST_CONFIG, config);
final HttpResponseInterceptor interceptor = new ResponseContentEncoding();
interceptor.process(response, context);
final HttpEntity entity = response.getEntity();
Assert.assertNotNull(entity);
Assert.assertFalse(entity instanceof GzipDecompressingEntity);
}
示例2: testParseCookies
import org.apache.http.HttpResponseInterceptor; //導入方法依賴的package包/類
@Test
public void testParseCookies() throws Exception {
final HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
response.addHeader(SM.SET_COOKIE, "name1=value1");
final HttpClientContext context = HttpClientContext.create();
context.setAttribute(HttpClientContext.COOKIE_ORIGIN, this.cookieOrigin);
context.setAttribute(HttpClientContext.COOKIE_SPEC, this.cookieSpec);
context.setAttribute(HttpClientContext.COOKIE_STORE, this.cookieStore);
final HttpResponseInterceptor interceptor = new ResponseProcessCookies();
interceptor.process(response, context);
final List<Cookie> cookies = this.cookieStore.getCookies();
Assert.assertNotNull(cookies);
Assert.assertEquals(1, cookies.size());
final Cookie cookie = cookies.get(0);
Assert.assertEquals(0, cookie.getVersion());
Assert.assertEquals("name1", cookie.getName());
Assert.assertEquals("value1", cookie.getValue());
Assert.assertEquals("localhost", cookie.getDomain());
Assert.assertEquals("/", cookie.getPath());
}
示例3: testNoCookieOrigin
import org.apache.http.HttpResponseInterceptor; //導入方法依賴的package包/類
@Test
public void testNoCookieOrigin() throws Exception {
final HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
response.addHeader(SM.SET_COOKIE, "name1=value1");
final HttpClientContext context = HttpClientContext.create();
context.setAttribute(HttpClientContext.COOKIE_ORIGIN, null);
context.setAttribute(HttpClientContext.COOKIE_SPEC, this.cookieSpec);
context.setAttribute(HttpClientContext.COOKIE_STORE, this.cookieStore);
final HttpResponseInterceptor interceptor = new ResponseProcessCookies();
interceptor.process(response, context);
final List<Cookie> cookies = this.cookieStore.getCookies();
Assert.assertNotNull(cookies);
Assert.assertEquals(0, cookies.size());
}
示例4: testNoCookieSpec
import org.apache.http.HttpResponseInterceptor; //導入方法依賴的package包/類
@Test
public void testNoCookieSpec() throws Exception {
final HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
response.addHeader(SM.SET_COOKIE, "name1=value1");
final HttpClientContext context = HttpClientContext.create();
context.setAttribute(HttpClientContext.COOKIE_ORIGIN, this.cookieOrigin);
context.setAttribute(HttpClientContext.COOKIE_SPEC, null);
context.setAttribute(HttpClientContext.COOKIE_STORE, this.cookieStore);
final HttpResponseInterceptor interceptor = new ResponseProcessCookies();
interceptor.process(response, context);
final List<Cookie> cookies = this.cookieStore.getCookies();
Assert.assertNotNull(cookies);
Assert.assertEquals(0, cookies.size());
}
示例5: testNoCookieStore
import org.apache.http.HttpResponseInterceptor; //導入方法依賴的package包/類
@Test
public void testNoCookieStore() throws Exception {
final HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
response.addHeader(SM.SET_COOKIE, "name1=value1");
final HttpClientContext context = HttpClientContext.create();
context.setAttribute(HttpClientContext.COOKIE_ORIGIN, this.cookieOrigin);
context.setAttribute(HttpClientContext.COOKIE_SPEC, this.cookieSpec);
context.setAttribute(HttpClientContext.COOKIE_STORE, null);
final HttpResponseInterceptor interceptor = new ResponseProcessCookies();
interceptor.process(response, context);
final List<Cookie> cookies = this.cookieStore.getCookies();
Assert.assertNotNull(cookies);
Assert.assertEquals(0, cookies.size());
}
示例6: testSetCookie2OverrideSetCookie
import org.apache.http.HttpResponseInterceptor; //導入方法依賴的package包/類
@Test
public void testSetCookie2OverrideSetCookie() throws Exception {
final HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
response.addHeader(SM.SET_COOKIE, "name1=value1");
response.addHeader(SM.SET_COOKIE2, "name1=value2; Version=1");
final HttpClientContext context = HttpClientContext.create();
context.setAttribute(HttpClientContext.COOKIE_ORIGIN, this.cookieOrigin);
context.setAttribute(HttpClientContext.COOKIE_SPEC, this.cookieSpec);
context.setAttribute(HttpClientContext.COOKIE_STORE, this.cookieStore);
final HttpResponseInterceptor interceptor = new ResponseProcessCookies();
interceptor.process(response, context);
final List<Cookie> cookies = this.cookieStore.getCookies();
Assert.assertNotNull(cookies);
Assert.assertEquals(1, cookies.size());
final Cookie cookie = cookies.get(0);
Assert.assertEquals(1, cookie.getVersion());
Assert.assertEquals("name1", cookie.getName());
Assert.assertEquals("value2", cookie.getValue());
Assert.assertEquals("localhost.local", cookie.getDomain());
Assert.assertEquals("/", cookie.getPath());
}
示例7: testInvalidHeader
import org.apache.http.HttpResponseInterceptor; //導入方法依賴的package包/類
@Test
public void testInvalidHeader() throws Exception {
final HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
response.addHeader(SM.SET_COOKIE2, "name=value; Version=crap");
final HttpClientContext context = HttpClientContext.create();
context.setAttribute(HttpClientContext.COOKIE_ORIGIN, this.cookieOrigin);
context.setAttribute(HttpClientContext.COOKIE_SPEC, this.cookieSpec);
context.setAttribute(HttpClientContext.COOKIE_STORE, this.cookieStore);
final HttpResponseInterceptor interceptor = new ResponseProcessCookies();
interceptor.process(response, context);
final List<Cookie> cookies = this.cookieStore.getCookies();
Assert.assertNotNull(cookies);
Assert.assertTrue(cookies.isEmpty());
}
示例8: testCookieRejected
import org.apache.http.HttpResponseInterceptor; //導入方法依賴的package包/類
@Test
public void testCookieRejected() throws Exception {
final HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
response.addHeader(SM.SET_COOKIE2, "name=value; Domain=www.somedomain.com; Version=1");
final HttpClientContext context = HttpClientContext.create();
context.setAttribute(HttpClientContext.COOKIE_ORIGIN, this.cookieOrigin);
context.setAttribute(HttpClientContext.COOKIE_SPEC, this.cookieSpec);
context.setAttribute(HttpClientContext.COOKIE_STORE, this.cookieStore);
final HttpResponseInterceptor interceptor = new ResponseProcessCookies();
interceptor.process(response, context);
final List<Cookie> cookies = this.cookieStore.getCookies();
Assert.assertNotNull(cookies);
Assert.assertTrue(cookies.isEmpty());
}
示例9: process
import org.apache.http.HttpResponseInterceptor; //導入方法依賴的package包/類
public void process(
final HttpResponse response,
final HttpContext context)
throws IOException, HttpException {
for (int i = 0; i < this.responseInterceptors.size(); i++) {
HttpResponseInterceptor interceptor =
this.responseInterceptors.get(i);
interceptor.process(response, context);
}
}
示例10: process
import org.apache.http.HttpResponseInterceptor; //導入方法依賴的package包/類
public void process(
final HttpResponse response,
final HttpContext context) throws IOException, HttpException {
for (final HttpResponseInterceptor responseInterceptor : this.responseInterceptors) {
responseInterceptor.process(response, context);
}
}
示例11: testContentEncodingNoEntity
import org.apache.http.HttpResponseInterceptor; //導入方法依賴的package包/類
@Test
public void testContentEncodingNoEntity() throws Exception {
final HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
final HttpContext context = new BasicHttpContext();
final HttpResponseInterceptor interceptor = new ResponseContentEncoding();
interceptor.process(response, context);
final HttpEntity entity = response.getEntity();
Assert.assertNull(entity);
}
示例12: testNoContentEncoding
import org.apache.http.HttpResponseInterceptor; //導入方法依賴的package包/類
@Test
public void testNoContentEncoding() throws Exception {
final HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
final StringEntity original = new StringEntity("plain stuff");
response.setEntity(original);
final HttpContext context = new BasicHttpContext();
final HttpResponseInterceptor interceptor = new ResponseContentEncoding();
interceptor.process(response, context);
final HttpEntity entity = response.getEntity();
Assert.assertNotNull(entity);
Assert.assertTrue(entity instanceof StringEntity);
}
示例13: testGzipContentEncoding
import org.apache.http.HttpResponseInterceptor; //導入方法依賴的package包/類
@Test
public void testGzipContentEncoding() throws Exception {
final HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
final StringEntity original = new StringEntity("encoded stuff");
original.setContentEncoding("GZip");
response.setEntity(original);
final HttpContext context = new BasicHttpContext();
final HttpResponseInterceptor interceptor = new ResponseContentEncoding();
interceptor.process(response, context);
final HttpEntity entity = response.getEntity();
Assert.assertNotNull(entity);
Assert.assertTrue(entity instanceof DecompressingEntity);
}
示例14: testGzipContentEncodingZeroLength
import org.apache.http.HttpResponseInterceptor; //導入方法依賴的package包/類
@Test
public void testGzipContentEncodingZeroLength() throws Exception {
final HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
final StringEntity original = new StringEntity("");
original.setContentEncoding("GZip");
response.setEntity(original);
final HttpContext context = new BasicHttpContext();
final HttpResponseInterceptor interceptor = new ResponseContentEncoding();
interceptor.process(response, context);
final HttpEntity entity = response.getEntity();
Assert.assertNotNull(entity);
Assert.assertTrue(entity instanceof StringEntity);
}
示例15: testXGzipContentEncoding
import org.apache.http.HttpResponseInterceptor; //導入方法依賴的package包/類
@Test
public void testXGzipContentEncoding() throws Exception {
final HttpResponse response = new BasicHttpResponse(HttpVersion.HTTP_1_1, 200, "OK");
final StringEntity original = new StringEntity("encoded stuff");
original.setContentEncoding("x-gzip");
response.setEntity(original);
final HttpContext context = new BasicHttpContext();
final HttpResponseInterceptor interceptor = new ResponseContentEncoding();
interceptor.process(response, context);
final HttpEntity entity = response.getEntity();
Assert.assertNotNull(entity);
Assert.assertTrue(entity instanceof DecompressingEntity);
}