當前位置: 首頁>>代碼示例>>Java>>正文


Java Response.getCookies方法代碼示例

本文整理匯總了Java中com.ning.http.client.Response.getCookies方法的典型用法代碼示例。如果您正苦於以下問題:Java Response.getCookies方法的具體用法?Java Response.getCookies怎麽用?Java Response.getCookies使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.ning.http.client.Response的用法示例。


在下文中一共展示了Response.getCookies方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: setResponse

import com.ning.http.client.Response; //導入方法依賴的package包/類
public void setResponse(String endpoint, Response response) throws IOException {

        Integer statusCode = response.getStatusCode();
        String httpResponse = response.getResponseBody();
        List<Cookie> cookies = response.getCookies();
        this.response = new HttpResponse(statusCode, httpResponse, cookies);
    }
 
開發者ID:Stratio,項目名稱:bdt,代碼行數:8,代碼來源:CommonG.java

示例2: testOptionalCachingOnJSESSIONIDCookie

import com.ning.http.client.Response; //導入方法依賴的package包/類
@Test
public void testOptionalCachingOnJSESSIONIDCookie() throws Exception {
    Map<String,String> filterInitParams = new HashMap<String,String>(1,1.0f) {{
        put(PublishToMemcachedFilter.MEMCACHED_KEY_PARAM,"$scheme$request_method$uri$args?$cookie_jsessionid?");
        put(PublishToMemcachedFilter.MEMCACHED_EXPIRY,"10");
    }};
    server.setupServlet3Filter("localhost:" + memcached.getPort(),null,filterInitParams);
    String url = server.setupServlet("/date/*","date","org.greencheek.web.filter.memcached.servlets.JSESSIONIDServlet",true);

    assertTrue(server.startTomcat());
    url = server.replacePort(url);
    Response response = executeGetRequest(url);
    assertEquals(CacheConfigGlobals.DEFAULT_CACHE_MISS_HEADER_VALUE,getCacheHeader(response));

    List<Cookie> cookies = response.getCookies();
    String sessionId = getSessionID(response);

    response = executeGetRequest(url,cookies);
    assertEquals(CacheConfigGlobals.DEFAULT_CACHE_MISS_HEADER_VALUE,getCacheHeader(response));

    response = executeGetRequest(url,cookies);
    assertEquals(CacheConfigGlobals.DEFAULT_CACHE_HIT_HEADER_VALUE,getCacheHeader(response));

    response = executeGetRequest(url);
    assertEquals(CacheConfigGlobals.DEFAULT_CACHE_HIT_HEADER_VALUE,getCacheHeader(response));
    assertEquals(sessionId, getSessionID(response));

    Cookie c = cookies.get(0);
    Cookie madeupJsessionId = new Cookie("JSESSIONID","xx","xx",c.getDomain(),c.getPath(),
            c.getExpires(),c.getMaxAge(),c.isSecure(),c.isHttpOnly());

    response = executeGetRequest(url, Collections.singletonList(madeupJsessionId));
    assertEquals(CacheConfigGlobals.DEFAULT_CACHE_MISS_HEADER_VALUE,getCacheHeader(response));
    assertNotEquals(sessionId, getSessionID(response));

}
 
開發者ID:tootedom,項目名稱:tomcat-memcached-response-filter,代碼行數:37,代碼來源:TestFilterConfiguration.java

示例3: getCookieString

import com.ning.http.client.Response; //導入方法依賴的package包/類
private String getCookieString(Response response, String key) {
    for(Cookie c : response.getCookies()) {
        if(c.getName().equalsIgnoreCase(key)) {
            return c.getValue();
        }
    }
    return "";
}
 
開發者ID:tootedom,項目名稱:tomcat-memcached-response-filter,代碼行數:9,代碼來源:TestFilterConfiguration.java

示例4: testCachingOnJSESSIONIDCookie

import com.ning.http.client.Response; //導入方法依賴的package包/類
@Test
public void testCachingOnJSESSIONIDCookie() throws Exception {
    Map<String,String> filterInitParams = new HashMap<String,String>(1,1.0f) {{
        put(PublishToMemcachedFilter.MEMCACHED_KEY_PARAM,"$scheme$request_method$uri$args?$cookie_jsessionid");
        put(PublishToMemcachedFilter.MEMCACHED_EXPIRY,"10");
    }};
    server.setupServlet3Filter("localhost:" + memcached.getPort(),null,filterInitParams);
    String url = server.setupServlet("/date/*","date","org.greencheek.web.filter.memcached.servlets.JSESSIONIDServlet",true);

    assertTrue(server.startTomcat());
    url = server.replacePort(url);
    Response response = executeGetRequest(url);
    assertEquals(CacheConfigGlobals.DEFAULT_CACHE_MISS_HEADER_VALUE, getCacheHeader(response));

    List<Cookie> cookies1 = response.getCookies();
    response = executeGetRequest(url,cookies1);
    assertEquals(CacheConfigGlobals.DEFAULT_CACHE_MISS_HEADER_VALUE,getCacheHeader(response));

    response = executeGetRequest(url,cookies1);
    assertEquals(CacheConfigGlobals.DEFAULT_CACHE_HIT_HEADER_VALUE,getCacheHeader(response));

    response = executeGetRequest(url);
    assertEquals(CacheConfigGlobals.DEFAULT_CACHE_MISS_HEADER_VALUE,getCacheHeader(response));


    List<Cookie> cookies2 = response.getCookies();
    // This request will cache.
    executeGetRequest(url,cookies2);

    // the request will get from the cache
    response = executeGetRequest(url,cookies2);
    String sessionId2 = getSessionID(response);
    assertEquals(CacheConfigGlobals.DEFAULT_CACHE_HIT_HEADER_VALUE,getCacheHeader(response));

    response = executeGetRequest(url,cookies1);

    String sessionId1 = getSessionID(response);
    assertEquals(CacheConfigGlobals.DEFAULT_CACHE_HIT_HEADER_VALUE,getCacheHeader(response));

    assertNotEquals("The two session ids must be different",sessionId1,sessionId2);

}
 
開發者ID:tootedom,項目名稱:tomcat-memcached-response-filter,代碼行數:43,代碼來源:TestFilterConfiguration.java


注:本文中的com.ning.http.client.Response.getCookies方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。