本文整理了Java中com.ning.http.client.Response.getCookies
方法的一些代码示例,展示了Response.getCookies
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Response.getCookies
方法的具体详情如下:
包路径:com.ning.http.client.Response
类名称:Response
方法名:getCookies
[英]Return the list of Cookie.
[中]返回Cookie列表。
代码示例来源:origin: com.ning/async-http-client
public List<Cookie> getCookies() {
return response.getCookies();
}
代码示例来源:origin: resthub/resthub-spring-stack
/**
* Get the cookies sent along the response
*/
public List<Cookie> getCookies() {
return ahcResponse.getCookies();
}
}
代码示例来源:origin: org.glassfish.grizzly/grizzly-http-client
public List<Cookie> getCookies() {
return response.getCookies();
}
代码示例来源:origin: io.gatling/async-http-client
public List<Cookie> getCookies() {
return response.getCookies();
}
代码示例来源:origin: javaee/grizzly-ahc
public List<Cookie> getCookies() {
return response.getCookies();
}
代码示例来源:origin: outbrain/ob1k
@Override
public List<Cookie> getCookies() {
return transformNingResponseCookies(ningResponse.getCookies());
}
代码示例来源:origin: javaee/grizzly-ahc
@Override
public Response onCompleted(Response response) throws Exception {
try {
assertEquals(response.getStatusCode(), 200);
List<Cookie> cookies = response.getCookies();
assertEquals(cookies.size(), 1);
assertEquals(cookies.get(0).toString(), "foo=value");
} finally {
l.countDown();
}
return response;
}
}).get();
代码示例来源:origin: net.adamcin.granite/granite-client-packman
private boolean loginLegacy(String username, String password) throws IOException {
Request request = getClient().preparePost(getBaseUrl() + LEGACY_PATH)
.addFormParam(LEGACY_PARAM_USERID, username)
.addFormParam(LEGACY_PARAM_PASSWORD, password)
.addFormParam(LEGACY_PARAM_WORKSPACE, LEGACY_VALUE_WORKSPACE)
.addFormParam(LEGACY_PARAM_TOKEN, LEGACY_VALUE_TOKEN)
.addFormParam(LOGIN_PARAM_CHARSET, LOGIN_VALUE_CHARSET).build();
try {
ListenableFuture<Response> fResponse = getClient().executeRequest(request);
Response response = getRequestTimeout() >= 0L ?
fResponse.get(getRequestTimeout(), TimeUnit.MILLISECONDS) : fResponse.get();
if (response.getStatusCode() == 200) {
this.setCookies(response.getCookies());
return true;
}
} catch (Exception e) {
throw new IOException("Failed to login with provided credentials");
}
return false;
}
代码示例来源:origin: net.adamcin.granite/granite-client-packman
@Override
public boolean login(String username, String password) throws IOException {
Request request = getClient().preparePost(getBaseUrl() + LOGIN_PATH)
.addFormParam(LOGIN_PARAM_USERNAME, username)
.addFormParam(LOGIN_PARAM_PASSWORD, password)
.addFormParam(LOGIN_PARAM_VALIDATE, LOGIN_VALUE_VALIDATE)
.addFormParam(LOGIN_PARAM_CHARSET, LOGIN_VALUE_CHARSET).build();
try {
ListenableFuture<Response> fResponse = getClient().executeRequest(request);
Response response = getRequestTimeout() >= 0L ?
fResponse.get(getRequestTimeout(), TimeUnit.MILLISECONDS) : fResponse.get();
if (response.getStatusCode() == 200) {
this.setCookies(response.getCookies());
return true;
} else if (response.getStatusCode() == 405) {
// fallback to legacy in case of 405 response
return loginLegacy(username, password);
}
} catch (Exception e) {
throw new IOException("Failed to login with provided credentials");
}
return false;
}
代码示例来源:origin: org.sonatype.spice/jersey-ahc-client
/**
* Translate the {@link ClientRequest} into a AsyncHttpClient request, and execute it.
*
* @param cr the HTTP request.
* @return the {@link ClientResponse}
* @throws ClientHandlerException
*/
@Override
public ClientResponse handle(final ClientRequest cr)
throws ClientHandlerException {
try {
final RequestBuilder requestBuilder = getRequestBuilder(cr);
handleCookie(requestBuilder);
requestWriter.configureRequest(requestBuilder, cr, allowBody(cr.getMethod()));
final Response response = client.executeRequest(requestBuilder.build()).get();
applyResponseCookies(response.getCookies());
ClientResponse r = new ClientResponse(response.getStatusCode(),
getInBoundHeaders(response),
response.getResponseBodyAsStream(),
workers);
if (!r.hasEntity()) {
r.bufferEntity();
r.close();
}
return r;
} catch (Exception e) {
throw new ClientHandlerException(e);
}
}
代码示例来源:origin: sonia.net.ahc/jersey-ahc-client
/**
* Translate the {@link ClientRequest} into a AsyncHttpClient request, and execute it.
*
* @param cr the HTTP request.
* @return the {@link ClientResponse}
* @throws ClientHandlerException
*/
@Override
public ClientResponse handle(final ClientRequest cr)
throws ClientHandlerException {
try {
final RequestBuilder requestBuilder = getRequestBuilder(cr);
handleCookie(requestBuilder);
requestWriter.configureRequest(requestBuilder, cr, allowBody(cr.getMethod()));
final Response response = client.executeRequest(requestBuilder.build()).get();
applyResponseCookies(response.getCookies());
ClientResponse r = new ClientResponse(response.getStatusCode(),
getInBoundHeaders(response),
response.getResponseBodyAsStream(),
workers);
if (!r.hasEntity()) {
r.bufferEntity();
r.close();
}
return r;
} catch (Exception e) {
throw new ClientHandlerException(e);
}
}
内容来源于网络,如有侵权,请联系作者删除!