本文整理汇总了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);
}