|
46 | 46 | import org.apache.commons.httpclient.cookie.CookiePolicy; |
47 | 47 | import org.apache.commons.httpclient.cookie.CookieSpec; |
48 | 48 | import org.apache.commons.httpclient.cookie.CookieVersionSupport; |
| 49 | +import org.apache.commons.httpclient.cookie.IgnoreCookiesSpec; |
49 | 50 | import org.apache.commons.httpclient.cookie.MalformedCookieException; |
50 | 51 | import org.apache.commons.httpclient.params.HttpMethodParams; |
51 | 52 | import org.apache.commons.httpclient.protocol.Protocol; |
@@ -1347,17 +1348,8 @@ protected void addCookieRequestHeader(HttpState state, HttpConnection conn) |
1347 | 1348 | } |
1348 | 1349 | Cookie[] cookies = matcher.match(host, conn.getPort(), |
1349 | 1350 | getPath(), conn.isSecure(), state.getCookies()); |
1350 | | - if ((cookies != null) && (cookies.length > 0)) { |
1351 | | - if (getParams().isParameterTrue(HttpMethodParams.SINGLE_COOKIE_HEADER)) { |
1352 | | - // In strict mode put all cookies on the same header |
1353 | | - putAllCookiesInASingleHeader(host, matcher, cookies); |
1354 | | - } else { |
1355 | | - // In non-strict mode put each cookie on a separate header |
1356 | | - for (int i = 0; i < cookies.length; i++) { |
1357 | | - String s = matcher.formatCookie(cookies[i]); |
1358 | | - getRequestHeaderGroup().addHeader(new Header(HttpHeader.COOKIE, s, true)); |
1359 | | - } |
1360 | | - } |
| 1351 | + if ((cookies != null && cookies.length > 0) || cookieheaders.length > 0) { |
| 1352 | + putAllCookiesInASingleHeader(host, matcher, cookies); |
1361 | 1353 | if (matcher instanceof CookieVersionSupport) { |
1362 | 1354 | CookieVersionSupport versupport = (CookieVersionSupport) matcher; |
1363 | 1355 | int ver = versupport.getVersion(); |
@@ -1407,6 +1399,10 @@ private void putAllCookiesInASingleHeader(String host, CookieSpec matcher, |
1407 | 1399 | mergedCookies.put(cookie.getName(),cookie); |
1408 | 1400 | } |
1409 | 1401 | cookies = mergedCookies.values().toArray(new Cookie[mergedCookies.size()]); |
| 1402 | + if (matcher instanceof IgnoreCookiesSpec) { |
| 1403 | + matcher = CookiePolicy.getCookieSpec(CookiePolicy.DEFAULT); |
| 1404 | + } |
| 1405 | + |
1410 | 1406 | String s = matcher.formatCookies(cookies); |
1411 | 1407 | getRequestHeaderGroup() |
1412 | 1408 | .addHeader(new Header(HttpHeader.COOKIE, s, true)); |
|
0 commit comments