Following up on r1804005, don't return the "response is truncated" error
code for an empty chunk size line.

While such empty line could be an indication of the truncated response,
it's not necessarily so.  The only thing we can say for sure in this
case is that the response is ill-formed, so tweak the code to return
an SERF_ERROR_BAD_HTTP_RESPONSE error.

* buckets/dechunk_buckets.c
  (wait_for_chunk): Remove an explicit check for an empty line, as this
   case is already handled below, after the apr_strtoi64() call.

* test/test_buckets.c
  (test_response_body_chunked_truncated_with_crlf): Rename this test to ...
  (test_response_body_chunked_bogus_crlf): ...this. Expect to receive
   the SERF_ERROR_BAD_HTTP_RESPONSE error.
  (test_buckets): Track the test rename.


git-svn-id: https://svn.apache.org/repos/asf/serf/trunk@1804016 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/buckets/dechunk_buckets.c b/buckets/dechunk_buckets.c
index 8a455b0..cea1974 100644
--- a/buckets/dechunk_buckets.c
+++ b/buckets/dechunk_buckets.c
@@ -84,11 +84,6 @@
             if (ctx->linebuf.state == SERF_LINEBUF_READY) {
                 char *end;
 
-                /* Do we have the chunk length? */
-                if (ctx->linebuf.line[0] == '\0') {
-                    return SERF_ERROR_TRUNCATED_HTTP_RESPONSE;
-                }
-
                 /* Convert from HEX digits. The linebuffer ensures a '\0' */
                 ctx->body_left = apr_strtoi64(ctx->linebuf.line, &end, 16);
                 if (errno == ERANGE) {
diff --git a/test/test_buckets.c b/test/test_buckets.c
index 274543b..068a3df 100644
--- a/test/test_buckets.c
+++ b/test/test_buckets.c
@@ -1125,7 +1125,7 @@
 /* Test for issue: the server aborts the connection and also sends
    a bogus CRLF in place of the expected chunk size. Test that we get
    a decent error code from the response bucket instead of APR_EOF. */
-static void test_response_body_chunked_truncated_with_crlf(CuTest *tc)
+static void test_response_body_chunked_bogus_crlf(CuTest *tc)
 {
     test_baton_t *tb = tc->testBaton;
     serf_bucket_t *bkt, *tmp;
@@ -1149,7 +1149,7 @@
 
         status = read_all(bkt, buf, sizeof(buf), &len);
 
-        CuAssertIntEquals(tc, SERF_ERROR_TRUNCATED_HTTP_RESPONSE, status);
+        CuAssertIntEquals(tc, SERF_ERROR_BAD_HTTP_RESPONSE, status);
     }
 
     /* This will also destroy response stream bucket. */
@@ -3282,7 +3282,7 @@
     SUITE_ADD_TEST(suite, test_response_body_chunked_no_crlf);
     SUITE_ADD_TEST(suite, test_response_body_chunked_incomplete_crlf);
     SUITE_ADD_TEST(suite, test_response_body_chunked_gzip_small);
-    SUITE_ADD_TEST(suite, test_response_body_chunked_truncated_with_crlf);
+    SUITE_ADD_TEST(suite, test_response_body_chunked_bogus_crlf);
     SUITE_ADD_TEST(suite, test_response_body_chunked_invalid_len);
     SUITE_ADD_TEST(suite, test_response_body_chunked_overflow_len);
     SUITE_ADD_TEST(suite, test_response_bucket_peek_at_headers);