You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by ol...@apache.org on 2004/09/16 08:46:32 UTC
cvs commit: jakarta-commons/httpclient/src/java/org/apache/commons/httpclient HttpMethodBase.java HttpState.java
olegk 2004/09/15 23:46:31
Modified: httpclient/src/java/org/apache/commons/httpclient
HttpMethodBase.java HttpState.java
Log:
PR #31211 (HttpState.setCookiePolicy() is completely ignored)
Problem fixed
Contributed by Oleg Kalnichevski
Reviewed by Michael Becke
Revision Changes Path
1.214 +15 -8 jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpMethodBase.java
Index: HttpMethodBase.java
===================================================================
RCS file: /home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpMethodBase.java,v
retrieving revision 1.213
retrieving revision 1.214
diff -u -r1.213 -r1.214
--- HttpMethodBase.java 15 Sep 2004 20:42:17 -0000 1.213
+++ HttpMethodBase.java 16 Sep 2004 06:46:30 -0000 1.214
@@ -1122,11 +1122,18 @@
/**
* Returns the actual cookie policy
*
+ * @param state HTTP state. TODO: to be removed in the future
+ *
* @return cookie spec
*/
- private CookieSpec getCookieSpec() {
+ private CookieSpec getCookieSpec(final HttpState state) {
if (this.cookiespec == null) {
- this.cookiespec = CookiePolicy.getCookieSpec(this.params.getCookiePolicy());
+ int i = state.getCookiePolicy();
+ if (i == -1) {
+ this.cookiespec = CookiePolicy.getCookieSpec(this.params.getCookiePolicy());
+ } else {
+ this.cookiespec = CookiePolicy.getSpecByPolicy(i);
+ }
this.cookiespec.setValidDateFormats(
(Collection)this.params.getParameter(HttpMethodParams.DATE_PATTERNS));
}
@@ -1160,7 +1167,7 @@
}
}
- CookieSpec matcher = getCookieSpec();
+ CookieSpec matcher = getCookieSpec(state);
Cookie[] cookies = matcher.match(conn.getHost(), conn.getPort(),
getPath(), conn.isSecure(), state.getCookies());
if ((cookies != null) && (cookies.length > 0)) {
@@ -1452,7 +1459,7 @@
headers = getResponseHeaderGroup().getHeaders("set-cookie");
}
- CookieSpec parser = getCookieSpec();
+ CookieSpec parser = getCookieSpec(state);
for (int i = 0; i < headers.length; i++) {
Header header = headers[i];
Cookie[] cookies = null;
1.36 +6 -6 jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpState.java
Index: HttpState.java
===================================================================
RCS file: /home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/HttpState.java,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -r1.35 -r1.36
--- HttpState.java 23 Jun 2004 06:50:25 -0000 1.35
+++ HttpState.java 16 Sep 2004 06:46:31 -0000 1.36
@@ -83,7 +83,7 @@
private boolean preemptive = false;
- private int cookiePolicy = 0;
+ private int cookiePolicy = -1;
// -------------------------------------------------------- Class Variables
/** Log object for this class. */
@@ -245,7 +245,7 @@
*/
public int getCookiePolicy() {
- return CookiePolicy.getDefaultPolicy();
+ return this.cookiePolicy;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org