You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nutch.apache.org by sn...@apache.org on 2019/05/24 13:23:24 UTC

[nutch] 02/04: When fixHttpHeaders is called with null, return null

This is an automated email from the ASF dual-hosted git repository.

snagel pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nutch.git

commit a83a736793a6f8bdc091acf73c1f00a48d25f4b6
Author: Yossi Tamari <yo...@pipl.com>
AuthorDate: Sun May 12 12:44:38 2019 +0300

    When fixHttpHeaders is called with null, return null
    
    Instead of NPE.
    This allows the WARC tools to create "resource" entries instead of
    failing.
---
 src/java/org/apache/nutch/tools/WARCUtils.java | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/java/org/apache/nutch/tools/WARCUtils.java b/src/java/org/apache/nutch/tools/WARCUtils.java
index 34365a8..1af6533 100644
--- a/src/java/org/apache/nutch/tools/WARCUtils.java
+++ b/src/java/org/apache/nutch/tools/WARCUtils.java
@@ -186,6 +186,9 @@ public class WARCUtils {
    * @return safe HTTP response header
    */
   public static final String fixHttpHeaders(String headers, int contentLength) {
+    if (headers==null) {
+      return null;
+    }
     int start = 0, lineEnd = 0, last = 0, trailingCrLf= 0;
     StringBuilder replace = new StringBuilder();
     while (start < headers.length()) {