HttpClient will no longer send expired cookies back to the origin server

git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@792269 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Oleg Kalnichevski 2009-07-08 19:10:52 +00:00
parent be2367cd91
commit 2b69ac0ae9
2 changed files with 15 additions and 4 deletions

View File

@ -1,6 +1,9 @@
Changes since 4.0 beta 2
-------------------
* HttpClient will no longer send expired cookies back to the origin server.
Contributed by Oleg Kalnichevski <olegk at apache.org>
* [HTTPCLIENT-856] Proxy NTLM authentication no longer fails on a redirect to
a different host.
Contributed by Oleg Kalnichevski <olegk at apache.org>

View File

@ -35,6 +35,7 @@ import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import net.jcip.annotations.Immutable;
@ -173,12 +174,19 @@ public class RequestAddCookies implements HttpRequestInterceptor {
List<Cookie> cookies = new ArrayList<Cookie>(cookieStore.getCookies());
// Find cookies matching the given origin
List<Cookie> matchedCookies = new ArrayList<Cookie>();
Date now = new Date();
for (Cookie cookie : cookies) {
if (cookieSpec.match(cookie, cookieOrigin)) {
if (this.log.isDebugEnabled()) {
this.log.debug("Cookie " + cookie + " match " + cookieOrigin);
if (cookie.getExpiryDate() == null || cookie.getExpiryDate().after(now)) {
if (cookieSpec.match(cookie, cookieOrigin)) {
if (this.log.isDebugEnabled()) {
this.log.debug("Cookie " + cookie + " match " + cookieOrigin);
}
matchedCookies.add(cookie);
}
} else {
if (this.log.isDebugEnabled()) {
this.log.debug("Cookie " + cookie + " expired");
}
matchedCookies.add(cookie);
}
}
// Generate Cookie request headers