use of org.apache.http.impl.cookie.BasicClientCookie in project warn-report by saaavsaaa.
the class WebRequestClient method testPostWithCookie.
public static String testPostWithCookie(String url, String cookieKey, String cookieValue, HttpEntity paras) throws Exception {
/*HttpContext localContext = new BasicHttpContext();
// 在本地上下问中绑定一个本地存储
localContext.setAttribute(HttpClientContext.COOKIE_STORE, cs);
cs.addCookie(new BasicClientCookie(cookieKey, cookieValue));*/
Cookie[] cookies = new Cookie[1];
cookies[0] = new BasicClientCookie(cookieKey, cookieValue);
setCookies(cookies);
return opera(url, paras, false);
}
use of org.apache.http.impl.cookie.BasicClientCookie in project sling-org-apache-sling-testing-clients by apache.
the class FormBasedAuthInterceptor method process.
@Override
public void process(HttpResponse response, HttpContext context) throws HttpException, IOException {
if (response.getStatusLine().getStatusCode() != HttpStatus.SC_UNAUTHORIZED) {
return;
}
if (URI.create(HttpClientContext.adapt(context).getRequest().getRequestLine().getUri()).getPath().endsWith(loginPath)) {
LOG.trace("Request ends with {} so I'm not intercepting the request", loginPath);
return;
}
Cookie loginCookie = getLoginCookie(context, loginTokenName);
if (loginCookie == null) {
return;
}
LOG.info("Response code was 401 even though {} is set. Removing the cookie.", loginCookie.getName());
BasicClientCookie expiredLoginTokenCookie = new BasicClientCookie(loginCookie.getName(), "expired");
// far enough in the past
expiredLoginTokenCookie.setExpiryDate(new Date(1));
expiredLoginTokenCookie.setDomain(loginCookie.getDomain());
expiredLoginTokenCookie.setPath(loginCookie.getPath());
HttpClientContext.adapt(context).getCookieStore().addCookie(expiredLoginTokenCookie);
}
use of org.apache.http.impl.cookie.BasicClientCookie in project acceptance-test-harness by jenkinsci.
the class Jenkins method buildHttpClientContext.
private HttpContext buildHttpClientContext() {
HttpClientContext context = HttpClientContext.create();
BasicCookieStore cookieStore = new BasicCookieStore();
for (org.openqa.selenium.Cookie cookie : driver.manage().getCookies()) {
BasicClientCookie c = new BasicClientCookie(cookie.getName(), cookie.getValue());
c.setPath(cookie.getPath());
c.setExpiryDate(cookie.getExpiry());
c.setDomain(cookie.getDomain());
cookieStore.addCookie(c);
}
context.setCookieStore(cookieStore);
return context;
}
Aggregations