Apache Nutch is an extensible and scalable web crawler
NUTCH-2576 HTTP protocol implementation based on okhttp - set Cookie header (same as in protocol-http)
Sebastian Nageldbdb40bcfacf
diff --git a/src/plugin/protocol-okhttp/src/java/org/apache/nutch/protocol/okhttp/OkHttpResponse.java b/src/plugin/protocol-okhttp/src/java/org/apache/nutch/protocol/okhttp/OkHttpResponse.javaindex 62def67a0..da24d7ca2 100644--- a/src/plugin/protocol-okhttp/src/java/org/apache/nutch/protocol/okhttp/OkHttpResponse.java+++ b/src/plugin/protocol-okhttp/src/java/org/apache/nutch/protocol/okhttp/OkHttpResponse.java@@ -22,11 +22,13 @@ import java.net.URL;import java.util.Base64;import org.apache.commons.lang.mutable.MutableBoolean;+import org.apache.hadoop.io.Text;import org.apache.nutch.crawl.CrawlDatum;import org.apache.nutch.metadata.Metadata;import org.apache.nutch.net.protocols.HttpDateFormat;import org.apache.nutch.net.protocols.Response;import org.apache.nutch.protocol.ProtocolException;+import org.apache.nutch.protocol.http.api.HttpBase;import org.slf4j.Logger;import org.slf4j.LoggerFactory;@@ -61,6 +63,13 @@ public class OkHttpResponse implements Response {HttpDateFormat.toString(datum.getModifiedTime()));}+ if (okhttp.isCookieEnabled()+ && datum.getMetaData().containsKey(HttpBase.COOKIE)) {+ String cookie = ((Text) datum.getMetaData().get(HttpBase.COOKIE))+ .toString();+ rb.header("Cookie", cookie);+ }+Request request = rb.build();okhttp3.Call call = okhttp.getClient().newCall(request);