serf-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kot...@apache.org
Subject svn commit: r1804016 - in /serf/trunk: buckets/dechunk_buckets.c test/test_buckets.c
Date Thu, 03 Aug 2017 15:54:20 GMT
Author: kotkov
Date: Thu Aug  3 15:54:20 2017
New Revision: 1804016

URL: http://svn.apache.org/viewvc?rev=1804016&view=rev
Log:
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.

Modified:
    serf/trunk/buckets/dechunk_buckets.c
    serf/trunk/test/test_buckets.c

Modified: serf/trunk/buckets/dechunk_buckets.c
URL: http://svn.apache.org/viewvc/serf/trunk/buckets/dechunk_buckets.c?rev=1804016&r1=1804015&r2=1804016&view=diff
==============================================================================
--- serf/trunk/buckets/dechunk_buckets.c (original)
+++ serf/trunk/buckets/dechunk_buckets.c Thu Aug  3 15:54:20 2017
@@ -84,11 +84,6 @@ static apr_status_t wait_for_chunk(serf_
             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) {

Modified: serf/trunk/test/test_buckets.c
URL: http://svn.apache.org/viewvc/serf/trunk/test/test_buckets.c?rev=1804016&r1=1804015&r2=1804016&view=diff
==============================================================================
--- serf/trunk/test/test_buckets.c (original)
+++ serf/trunk/test/test_buckets.c Thu Aug  3 15:54:20 2017
@@ -1125,7 +1125,7 @@ static void test_response_body_chunked_g
 /* 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 @@ static void test_response_body_chunked_t
 
         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 @@ CuSuite *test_buckets(void)
     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);



Mime
View raw message