]> granicus.if.org Git - apache/commitdiff
handling body of chunked requests without content-length and content-type correctly
authorStefan Eissing <icing@apache.org>
Tue, 17 Nov 2015 10:26:38 +0000 (10:26 +0000)
committerStefan Eissing <icing@apache.org>
Tue, 17 Nov 2015 10:26:38 +0000 (10:26 +0000)
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1714751 13f79535-47bb-0310-9956-ffa450edef68

modules/http2/h2_request.c

index 27c57577029e9bfe197db2b06f8f56251c8fe8ff..2d8dcda27c8e43dabafa714fb0823e553ae1c372 100644 (file)
@@ -254,18 +254,21 @@ apr_status_t h2_request_end_headers(h2_request *req, apr_pool_t *pool, int eos)
     else {
         /* no content-length given */
         req->content_length = -1;
-        s = apr_table_get(req->headers, "Content-Type");
-        if (eos && s) {
-            req->chunked = 0;
-            apr_table_setn(req->headers, "Content-Length", "0");
-        }
-        else if (s) {
-            /* We have not seen a content-length, but a content-type. 
-             * must pass any request content in chunked form.
+        if (!eos) {
+            /* We have not seen a content-length and have no eos,
+             * simulate a chunked encoding for our HTTP/1.1 infrastructure,
+             * in case we have "H2SerializeHeaders on" here
              */
             req->chunked = 1;
             apr_table_mergen(req->headers, "Transfer-Encoding", "chunked");
         }
+        else if (apr_table_get(req->headers, "Content-Type")) {
+            /* If we have a content-type, but already see eos, no more
+             * data will come. Signal a zero content length explicitly.
+             */
+            req->chunked = 0;
+            apr_table_setn(req->headers, "Content-Length", "0");
+        }
     }
 
     req->eoh = 1;