You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by "Roy T. Fielding" <fi...@kiwi.ics.uci.edu> on 1997/11/14 19:17:31 UTC

Re: [PATCH] protocol/1399: failing to read body

>Nyet.  
>
>    if (r->read_length || is_HTTP_ERROR(r->status))
>        return 0;
>
>makes should_client_block return 0 because we are returning a 401, so the
>body is never read.

*sigh*  That's the third time that stupid hack has bitten me.
We don't need it any more, and if removing it does reveal another
side-effect problem then we will fix the source of the problem and
not the side-effect.  Updated patch below.

....Roy

Index: http_protocol.c
===================================================================
RCS file: /export/home/cvs/apachen/src/main/http_protocol.c,v
retrieving revision 1.169
diff -u -r1.169 http_protocol.c
--- http_protocol.c	1997/11/01 22:24:08	1.169
+++ http_protocol.c	1997/11/14 18:28:19
@@ -1386,13 +1386,13 @@
 
 API_EXPORT(int) should_client_block(request_rec *r)
 {
-    if (r->read_length || is_HTTP_ERROR(r->status))
-        return 0;
+    /* First check if we have already read the request body */
 
-    if (!r->read_chunked && (r->remaining <= 0))
+    if (r->read_length || (!r->read_chunked && (r->remaining <= 0)))
         return 0;
 
-    if (r->proto_num >= HTTP_VERSION(1,1)) { /* sending 100 Continue interim response */
+    if (r->proto_num >= HTTP_VERSION(1,1)) {
+        /* sending 100 Continue interim response */
         bvputs(r->connection->client,
                SERVER_PROTOCOL, " ", status_lines[0], "\015\012\015\012",
                NULL);
Index: http_request.c
===================================================================
RCS file: /export/home/cvs/apachen/src/main/http_request.c,v
retrieving revision 1.92
diff -u -r1.92 http_request.c
--- http_request.c	1997/11/08 21:39:11	1.92
+++ http_request.c	1997/11/14 18:28:20
@@ -887,6 +887,17 @@
     }
 
     /*
+     * If we want to keep the connection, be sure that the request body
+     * (if any) has been read.
+     */
+    if ((r->status != HTTP_NOT_MODIFIED) && (r->status != HTTP_NO_CONTENT)
+        && !status_drops_connection(r->status)
+        && r->connection && (r->connection->keepalive != -1)) {
+
+        (void) discard_request_body(r);
+    }
+
+    /*
      * Two types of custom redirects --- plain text, and URLs. Plain text has
      * a leading '"', so the URL code, here, is triggered on its absence
      */