Skip to content

Commit

Permalink
fix processing multiple set-cookie headers
Browse files Browse the repository at this point in the history
  • Loading branch information
SurenSritharan committed Mar 2, 2023
1 parent 94060bd commit 58669d2
Showing 1 changed file with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -595,13 +595,18 @@ private String extractRedirectLocation(ContentResponse contentResponse) {
return redirectLocation;
}

private void saveCookiesInCookieManager(ContentResponse response, URL url,
CookieManager cookieManager) {
String cookieHeader = response.getHeaders().get(HTTPConstants.HEADER_SET_COOKIE);
if (cookieHeader != null && cookieManager != null) {
cookieManager.addCookieFromHeader(cookieHeader, url);
}
}
private void saveCookiesInCookieManager(ContentResponse response, URL url, CookieManager cookieManager) {
Iterator<HttpField> iterator = response.getHeaders().iterator();
while (iterator.hasNext()) {
HttpField field = iterator.next();
if (field.is(HTTPConstants.HEADER_SET_COOKIE)) {
String cookieHeader = field.getValue();
if (cookieHeader != null && cookieManager != null) {
cookieManager.addCookieFromHeader(cookieHeader, url);
}
}
}
}

public void clearCookies() {
httpClient.getCookieStore().removeAll();
Expand Down

0 comments on commit 58669d2

Please sign in to comment.