rwaldhoff 01/06/28 18:41:07
Modified: httpclient/src/java/org/apache/commons/httpclient
Cookie.java
Log:
only submit a cookie if it hasn't already expired
Revision Changes Path
1.4 +8 -6
jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/Cookie.java
Index: Cookie.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/Cookie.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Cookie.java 2001/06/27 20:40:05 1.3
+++ Cookie.java 2001/06/29 01:41:06 1.4
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/Cookie.java,v
1.3 2001/06/27 20:40:05 morgand Exp $
- * $Revision: 1.3 $
- * $Date: 2001/06/27 20:40:05 $
+ * $Header:
/home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/Cookie.java,v
1.4 2001/06/29 01:41:06 rwaldhoff Exp $
+ * $Revision: 1.4 $
+ * $Date: 2001/06/29 01:41:06 $
*
* ====================================================================
*
@@ -302,7 +302,7 @@
// The terms request-host and request-URI refer to the values the client
// would send to the server as, respectively, the host (but not port)
// and abs_path portions of the absoluteURI (http_URL) of the HTTP
- // request line.
+ // request line.
//
// RFC2965 includes ports in cookie-sending determination, but only
// when the cookie is received via a 'Set-Cookie2' header.
@@ -321,10 +321,12 @@
// FIXME: cookies are supposed to be ordered with "better"
// matches first
+ Date now = new Date();
for (Enumeration e = cookies.elements(); e.hasMoreElements(); ) {
Cookie cookie = (Cookie) e.nextElement();
- if (domain.endsWith(cookie.getDomain()) &&
- ((cookie.getPath() == null) ||
+ if ((cookie.getExpiryDate() == null ||
cookie.getExpiryDate().after(now)) && // only add the cookie if it hasn't yet expired
+ domain.endsWith(cookie.getDomain()) &&
// and the domain pattern matches
+ ((cookie.getPath() == null) ||
// and the path is null or matching
(path.startsWith(cookie.getPath())))) {
value.append(";");
value.append(cookie.toExternalForm());