Author: rhuijben
Date: Thu Nov 26 14:37:58 2015
New Revision: 1716701

URL: http://svn.apache.org/viewvc?rev=1716701&view=rev
Log:
Make the response bucket properly read trailers even when the caller uses
other read methods than the normal read: the iovec and readline versions
both suffered from this problem.

* buckets/response_buckets.c
  (serf_response_readline,
   serf_response_read_iovec): Implement trailer support in the same
     way the normal read supports this.

Modified:
    serf/trunk/buckets/response_buckets.c

Modified: serf/trunk/buckets/response_buckets.c
URL: 
http://svn.apache.org/viewvc/serf/trunk/buckets/response_buckets.c?rev=1716701&r1=1716700&r2=1716701&view=diff
==============================================================================
--- serf/trunk/buckets/response_buckets.c (original)
+++ serf/trunk/buckets/response_buckets.c Thu Nov 26 14:37:58 2015
@@ -634,12 +634,20 @@ static apr_status_t serf_response_readli
     /* Delegate to the stream bucket to do the readline. */
     status = serf_bucket_readline(ctx->body, acceptable, found, data, len);
 
+    if (APR_STATUS_IS_EOF(status)) {
+        if (ctx->chunked) {
+            ctx->state = STATE_TRAILERS;
+            /* Mask the result. */
+            status = APR_SUCCESS;
+        }
+        else {
+            ctx->state = STATE_DONE;
+        }
+    }
+
 fake_eof:
-    if (APR_STATUS_IS_EOF(status) && ctx->error_on_eof) {
-        *len = 0;
-        *found = SERF_NEWLINE_NONE;
+    if (APR_STATUS_IS_EOF(status) && ctx->error_on_eof)
         return ctx->error_on_eof;
-    }
 
     return status;
 }
@@ -662,6 +670,17 @@ static apr_status_t serf_response_read_i
     status = serf_bucket_read_iovec(ctx->body, requested, vecs_size,
                                     vecs, vecs_used);
 
+    if (APR_STATUS_IS_EOF(status)) {
+        if (ctx->chunked) {
+            ctx->state = STATE_TRAILERS;
+            /* Mask the result. */
+            status = APR_SUCCESS;
+        }
+        else {
+            ctx->state = STATE_DONE;
+        }
+    }
+
 fake_eof:
     if (APR_STATUS_IS_EOF(status) && ctx->error_on_eof)
         return ctx->error_on_eof;


Reply via email to