]> granicus.if.org Git - apache/commitdiff
mod_http2: merged from trunk, sending out push promises *before* the stream response...
authorStefan Eissing <icing@apache.org>
Tue, 8 Dec 2015 11:03:31 +0000 (11:03 +0000)
committerStefan Eissing <icing@apache.org>
Tue, 8 Dec 2015 11:03:31 +0000 (11:03 +0000)
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1718559 13f79535-47bb-0310-9956-ffa450edef68

modules/http2/h2_session.c

index 4e3bb8f38be439ea2379351864ef7e1c86714e4a..1d79364e87832ebef77c9d0d86a1fde66d80dddd 100644 (file)
@@ -1230,23 +1230,14 @@ static apr_status_t submit_response(h2_session *session, h2_stream *stream)
                       "h2_stream(%ld-%d): submit response %d",
                       session->id, stream->id, response->http_status);
         
-        prio = h2_stream_get_priority(stream);
-        if (prio) {
-            h2_session_set_prio(session, stream, prio);
-            /* no showstopper if that fails for some reason */
-        }
-        
-        ngh = h2_util_ngheader_make_res(stream->pool, response->http_status, 
-                                        response->headers);
-        rv = nghttp2_submit_response(session->ngh2, response->stream_id,
-                                     ngh->nv, ngh->nvlen, &provider);
-        
-        /* If the submit worked,
-         * and this stream is not a pushed one itself,
+        /* If this stream is not a pushed one itself,
          * and HTTP/2 server push is enabled here,
          * and the response is in the range 200-299 *),
          * and the remote side has pushing enabled,
          * -> find and perform any pushes on this stream
+         *    *before* we submit the stream response itself.
+         *    This helps clients avoid opening new streams on Link
+         *    headers that get pushed right afterwards.
          * 
          * *) the response code is relevant, as we do not want to 
          *    make pushes on 401 or 403 codes, neiterh on 301/302
@@ -1254,14 +1245,25 @@ static apr_status_t submit_response(h2_session *session, h2_stream *stream)
          *    as the client, having this resource in its cache, might
          *    also have the pushed ones as well.
          */
-        if (!rv 
-            && !stream->initiated_on
+        if (!stream->initiated_on
             && h2_config_geti(session->config, H2_CONF_PUSH)
             && H2_HTTP_2XX(response->http_status)
             && h2_session_push_enabled(session)) {
             
             h2_stream_submit_pushes(stream);
         }
+        
+        prio = h2_stream_get_priority(stream);
+        if (prio) {
+            h2_session_set_prio(session, stream, prio);
+            /* no showstopper if that fails for some reason */
+        }
+        
+        ngh = h2_util_ngheader_make_res(stream->pool, response->http_status, 
+                                        response->headers);
+        rv = nghttp2_submit_response(session->ngh2, response->stream_id,
+                                     ngh->nv, ngh->nvlen, &provider);
+        
     }
     else {
         int err = H2_STREAM_RST(stream, H2_ERR_PROTOCOL_ERROR);