Skip to content

armgit / nutch

Public Imported from GitHub
0

Apache Nutch is an extensible and scalable web crawler

NUTCH-2432 Protocol httpclient to disable cookies if http.enable.cookie.header is false (contributed by Markus Jelsma)

Sebastian Nagel9d42fcfcd749
diff --git a/src/plugin/protocol-httpclient/src/java/org/apache/nutch/protocol/httpclient/HttpResponse.java b/src/plugin/protocol-httpclient/src/java/org/apache/nutch/protocol/httpclient/HttpResponse.java
index 863a02b37..05b9e2a68 100644
--- a/src/plugin/protocol-httpclient/src/java/org/apache/nutch/protocol/httpclient/HttpResponse.java
+++ b/src/plugin/protocol-httpclient/src/java/org/apache/nutch/protocol/httpclient/HttpResponse.java
@@ -88,8 +88,13 @@ public class HttpResponse implements Response {
}
params.makeLenient();
params.setContentCharset("UTF-8");
- params.setCookiePolicy(CookiePolicy.BROWSER_COMPATIBILITY);
- params.setBooleanParameter(HttpMethodParams.SINGLE_COOKIE_HEADER, true);
+
+ if (http.isCookieEnabled()) {
+ params.setCookiePolicy(CookiePolicy.BROWSER_COMPATIBILITY);
+ params.setBooleanParameter(HttpMethodParams.SINGLE_COOKIE_HEADER, true);
+ } else {
+ params.setCookiePolicy(CookiePolicy.IGNORE_COOKIES);
+ }
// XXX (ab) not sure about this... the default is to retry 3 times; if
// XXX the request body was sent the method is not retried, so there is
// XXX little danger in retrying...