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
The following commit(s) were added to refs/heads/master by this push:
new 9449417 NUTCH-2763 protocol-okhttp (store.http.headers): add
whitespace in status line after status code also when message is empty
new ebc2152 Merge pull request #498 from
sebastian-nagel/NUTCH-2763-protocol-okhttp-store-headers-status-line
9449417 is described below
commit 944941746708279340fb3be879802b1c899a48da
Author: Sebastian Nagel <[email protected]>
AuthorDate: Thu Feb 20 10:01:32 2020 +0100
NUTCH-2763 protocol-okhttp (store.http.headers): add whitespace in status
line after status code also when message is empty
---
.../src/java/org/apache/nutch/protocol/okhttp/OkHttp.java | 7 ++-----
.../nutch/protocol/okhttp/TestBadServerResponses.java | 15 +++++++++++++++
2 files changed, 17 insertions(+), 5 deletions(-)
diff --git
a/src/plugin/protocol-okhttp/src/java/org/apache/nutch/protocol/okhttp/OkHttp.java
b/src/plugin/protocol-okhttp/src/java/org/apache/nutch/protocol/okhttp/OkHttp.java
index 708863b..9fbe9fa 100644
---
a/src/plugin/protocol-okhttp/src/java/org/apache/nutch/protocol/okhttp/OkHttp.java
+++
b/src/plugin/protocol-okhttp/src/java/org/apache/nutch/protocol/okhttp/OkHttp.java
@@ -280,11 +280,8 @@ public class OkHttp extends HttpBase {
responseverbatim = new StringBuilder();
responseverbatim.append(getNormalizedProtocolName(response.protocol()))
- .append(' ').append(response.code());
- if (!response.message().isEmpty()) {
- responseverbatim.append(' ').append(response.message());
- }
- responseverbatim.append("\r\n");
+ .append(' ').append(response.code()).append(' ')
+ .append(response.message()).append("\r\n");
Headers headers = response.headers();
diff --git
a/src/plugin/protocol-okhttp/src/test/org/apache/nutch/protocol/okhttp/TestBadServerResponses.java
b/src/plugin/protocol-okhttp/src/test/org/apache/nutch/protocol/okhttp/TestBadServerResponses.java
index 34c5f6f..dafe365 100644
---
a/src/plugin/protocol-okhttp/src/test/org/apache/nutch/protocol/okhttp/TestBadServerResponses.java
+++
b/src/plugin/protocol-okhttp/src/test/org/apache/nutch/protocol/okhttp/TestBadServerResponses.java
@@ -477,4 +477,19 @@ public class TestBadServerResponses {
(kB * 1024), fetched.getContent().getContent().length);
}
+ /**
+ * NUTCH-2763 store.http.headers: add whitespace in status line after status
+ * code also when message is empty
+ */
+ @Test
+ public void testHttpStatusNoMessage() throws Exception {
+ setUp();
+ String statusLineNoMessage = "HTTP/1.1 200 \r\n";
+ launchServer(statusLineNoMessage + simpleContent);
+ ProtocolOutput fetched = fetchPage("/", 200);
+ assertTrue(
+ "Invalid HTTP status line (see NUTCH-2763, missing whitespace between
status code and message)",
+ getHeaders(fetched).startsWith(statusLineNoMessage));
+ }
+
}