本文整理匯總了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);
}
示例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));
}
示例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 "";
}
示例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);
}