"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
* 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);