Commit 210ebddf authored by Stefan Eissing's avatar Stefan Eissing
Browse files

mod_http2: merged from trunk, sending out push promises *before* the stream...

mod_http2: merged from trunk, sending out push promises *before* the stream response to make client handling of preload links easier

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1718559 13f79535-47bb-0310-9956-ffa450edef68
parent d1a6ece8
Loading
Loading
Loading
Loading
+17 −15
Original line number Diff line number Diff line
@@ -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);