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


Java HttpResponseInterceptor.process方法代码示例

本文整理汇总了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);
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:21,代码来源:TestResponseContentEncoding.java

示例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());
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:24,代码来源:TestResponseProcessCookies.java

示例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());
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:18,代码来源:TestResponseProcessCookies.java

示例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());
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:18,代码来源:TestResponseProcessCookies.java

示例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());
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:18,代码来源:TestResponseProcessCookies.java

示例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());
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:25,代码来源:TestResponseProcessCookies.java

示例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());
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:18,代码来源:TestResponseProcessCookies.java

示例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());
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:18,代码来源:TestResponseProcessCookies.java

示例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);
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:11,代码来源:BasicHttpProcessor.java

示例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);
    }
}
 
开发者ID:xxonehjh,项目名称:remote-files-sync,代码行数:8,代码来源:ImmutableHttpProcessor.java

示例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);
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:11,代码来源:TestResponseContentEncoding.java

示例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);
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:14,代码来源:TestResponseContentEncoding.java

示例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);
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:15,代码来源:TestResponseContentEncoding.java

示例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);
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:15,代码来源:TestResponseContentEncoding.java

示例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);
}
 
开发者ID:MyPureCloud,项目名称:purecloud-iot,代码行数:15,代码来源:TestResponseContentEncoding.java


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