Author: rhuijben
Date: Wed Nov 18 11:09:39 2015
New Revision: 1714969

URL: http://svn.apache.org/viewvc?rev=1714969&view=rev
Log:
Introduce a specific error code for unframing buckets to tell that there are
no more frames, to allow differentiating between no more frames at EOF and
a truncated frame header.

* buckets/fcgi_buckets.c
  (serf__bucket_fcgi_unframe_read_info): Handle no-frame properly.

* buckets/http2_frame_buckets.c
  (serf__bucket_http2_unframe_read_info): Handle no-frame properly.

* context.c
  (serf_error_string): Add error message.

* serf.h
  (SERF_ERROR_EMPTY_STREAM): Define.

Modified:
    serf/trunk/buckets/fcgi_buckets.c
    serf/trunk/buckets/http2_frame_buckets.c
    serf/trunk/context.c
    serf/trunk/serf.h

Modified: serf/trunk/buckets/fcgi_buckets.c
URL: 
http://svn.apache.org/viewvc/serf/trunk/buckets/fcgi_buckets.c?rev=1714969&r1=1714968&r2=1714969&view=diff
==============================================================================
--- serf/trunk/buckets/fcgi_buckets.c (original)
+++ serf/trunk/buckets/fcgi_buckets.c Wed Nov 18 11:09:39 2015
@@ -144,7 +144,10 @@ apr_status_t serf__bucket_fcgi_unframe_r
         {
             /* Reading frame failed because we couldn't read the header. Report
                a read failure instead of semi-success */
-            status = SERF_ERROR_TRUNCATED_STREAM;
+            if (ctx->record_remaining == FCGI_RECORD_SIZE)
+                status = SERF_ERROR_EMPTY_STREAM;
+            else
+                status = SERF_ERROR_TRUNCATED_STREAM;
         }
         else if (!status)
             status = APR_EAGAIN;

Modified: serf/trunk/buckets/http2_frame_buckets.c
URL: 
http://svn.apache.org/viewvc/serf/trunk/buckets/http2_frame_buckets.c?rev=1714969&r1=1714968&r2=1714969&view=diff
==============================================================================
--- serf/trunk/buckets/http2_frame_buckets.c (original)
+++ serf/trunk/buckets/http2_frame_buckets.c Wed Nov 18 11:09:39 2015
@@ -180,7 +180,10 @@ serf__bucket_http2_unframe_read_info(ser
         else if (APR_STATUS_IS_EOF(status)) {
           /* Reading frame failed because we couldn't read the header. Report
              a read failure instead of semi-success */
-            status = SERF_ERROR_HTTP2_FRAME_SIZE_ERROR;
+            if (ctx->prefix_remaining == FRAME_PREFIX_SIZE)
+                status = SERF_ERROR_EMPTY_STREAM;
+            else
+                status = SERF_ERROR_HTTP2_FRAME_SIZE_ERROR;
         }
         else if (!status)
             status = APR_EAGAIN;

Modified: serf/trunk/context.c
URL: 
http://svn.apache.org/viewvc/serf/trunk/context.c?rev=1714969&r1=1714968&r2=1714969&view=diff
==============================================================================
--- serf/trunk/context.c (original)
+++ serf/trunk/context.c Wed Nov 18 11:09:39 2015
@@ -408,6 +408,9 @@ const char *serf_error_string(apr_status
         return "The connection timed out";
     case SERF_ERROR_TRUNCATED_STREAM:
         return "The stream returned less data than was expected";
+    case SERF_ERROR_EMPTY_STREAM:
+        return "The stream is empty";
+
     case SERF_ERROR_SSL_COMM_FAILED:
         return "An error occurred during SSL communication";
     case SERF_ERROR_SSL_SETUP_FAILED:

Modified: serf/trunk/serf.h
URL: 
http://svn.apache.org/viewvc/serf/trunk/serf.h?rev=1714969&r1=1714968&r2=1714969&view=diff
==============================================================================
--- serf/trunk/serf.h (original)
+++ serf/trunk/serf.h Wed Nov 18 11:09:39 2015
@@ -109,6 +109,8 @@ typedef struct serf_config_t serf_config
 #define SERF_ERROR_CONNECTION_TIMEDOUT (SERF_ERROR_START + 12)
 /* The stream returned less data than was expected */
 #define SERF_ERROR_TRUNCATED_STREAM (SERF_ERROR_START + 13)
+/* The stream is empty */
+#define SERF_ERROR_EMPTY_STREAM (SERF_ERROR_START + 14)
 
 /* Http-2 stream errors, mapped into our error range */
 #define SERF_ERROR_HTTP2_NO_ERROR (SERF_ERROR_START + 50)


Reply via email to