當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。