From: Stefan Eissing Date: Tue, 8 Dec 2015 11:03:31 +0000 (+0000) Subject: mod_http2: merged from trunk, sending out push promises *before* the stream response... X-Git-Tag: 2.4.18~7 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=85a5ec3d907fd07868eff3fb12e19fc566a8179f;p=apache 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 --- diff --git a/modules/http2/h2_session.c b/modules/http2/h2_session.c index 4e3bb8f38b..1d79364e87 100644 --- a/modules/http2/h2_session.c +++ b/modules/http2/h2_session.c @@ -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);