diff options
author | Stefan Eissing <icing@apache.org> | 2017-04-14 17:08:32 +0200 |
---|---|---|
committer | Stefan Eissing <icing@apache.org> | 2017-04-14 17:08:32 +0200 |
commit | c66d4fc74ee76fcbb6c1494ae0dbb95d5bb4179f (patch) | |
tree | 6cae8f8af236367c1e4c7c75cbb3bad73460631c /modules/http2/h2_session.c | |
parent | xforms (diff) | |
download | apache2-c66d4fc74ee76fcbb6c1494ae0dbb95d5bb4179f.tar.xz apache2-c66d4fc74ee76fcbb6c1494ae0dbb95d5bb4179f.zip |
On the trunk:
mod_http2: only when 'HttpProtocolOptions Unsafe' is configured, will
control characters in response headers or trailers be forwarded to the
client. Otherwise, in the default configuration, a request will eiher
fail with status 500 or the stream will be reset by a RST_STREAM frame.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1791377 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'modules/http2/h2_session.c')
-rw-r--r-- | modules/http2/h2_session.c | 66 |
1 files changed, 42 insertions, 24 deletions
diff --git a/modules/http2/h2_session.c b/modules/http2/h2_session.c index 997d6fb00e..185580bf25 100644 --- a/modules/http2/h2_session.c +++ b/modules/http2/h2_session.c @@ -1080,13 +1080,16 @@ struct h2_stream *h2_session_push(h2_session *session, h2_stream *is, { h2_stream *stream; h2_ngheader *ngh; - int nid; + apr_status_t status; + int nid = 0; - ngh = h2_util_ngheader_make_req(is->pool, push->req); - nid = nghttp2_submit_push_promise(session->ngh2, 0, is->id, - ngh->nv, ngh->nvlen, NULL); - if (nid <= 0) { - ap_log_cerror(APLOG_MARK, APLOG_DEBUG, 0, session->c, + status = h2_req_create_ngheader(&ngh, is->pool, push->req); + if (status == APR_SUCCESS) { + nid = nghttp2_submit_push_promise(session->ngh2, 0, is->id, + ngh->nv, ngh->nvlen, NULL); + } + if (status != APR_SUCCESS || nid <= 0) { + ap_log_cerror(APLOG_MARK, APLOG_DEBUG, status, session->c, H2_STRM_LOG(APLOGNO(03075), is, "submitting push promise fail: %s"), nghttp2_strerror(nid)); return NULL; @@ -1280,16 +1283,25 @@ static apr_status_t on_stream_headers(h2_session *session, h2_stream *stream, else if (stream->has_response) { h2_ngheader *nh; - nh = h2_util_ngheader_make(stream->pool, headers->headers); - ap_log_cerror(APLOG_MARK, APLOG_DEBUG, 0, session->c, - H2_STRM_LOG(APLOGNO(03072), stream, "submit %d trailers"), (int)nh->nvlen); - rv = nghttp2_submit_trailer(session->ngh2, stream->id, nh->nv, nh->nvlen); + status = h2_res_create_ngtrailer(&nh, stream->pool, headers); + + ap_log_cerror(APLOG_MARK, APLOG_DEBUG, status, session->c, + H2_STRM_LOG(APLOGNO(03072), stream, "submit %d trailers"), + (int)nh->nvlen); + if (status == APR_SUCCESS) { + rv = nghttp2_submit_trailer(session->ngh2, stream->id, + nh->nv, nh->nvlen); + } + else { + ap_log_cerror(APLOG_MARK, APLOG_DEBUG, status, session->c, + H2_STRM_LOG(APLOGNO(), stream, "invalid trailers")); + h2_stream_rst(stream, NGHTTP2_PROTOCOL_ERROR); + } goto leave; } else { nghttp2_data_provider provider, *pprovider = NULL; h2_ngheader *ngh; - apr_table_t *hout; const char *note; ap_log_cerror(APLOG_MARK, APLOG_DEBUG, 0, session->c, @@ -1335,17 +1347,16 @@ static apr_status_t on_stream_headers(h2_session *session, h2_stream *stream, } h2_session_set_prio(session, stream, stream->pref_priority); - hout = headers->headers; note = apr_table_get(headers->notes, H2_FILTER_DEBUG_NOTE); if (note && !strcmp("on", note)) { int32_t connFlowIn, connFlowOut; connFlowIn = nghttp2_session_get_effective_local_window_size(session->ngh2); connFlowOut = nghttp2_session_get_remote_window_size(session->ngh2); - hout = apr_table_clone(stream->pool, hout); - apr_table_setn(hout, "conn-flow-in", + headers = h2_headers_copy(stream->pool, headers); + apr_table_setn(headers->headers, "conn-flow-in", apr_itoa(stream->pool, connFlowIn)); - apr_table_setn(hout, "conn-flow-out", + apr_table_setn(headers->headers, "conn-flow-out", apr_itoa(stream->pool, connFlowOut)); } @@ -1357,17 +1368,24 @@ static apr_status_t on_stream_headers(h2_session *session, h2_stream *stream, goto leave; } - ngh = h2_util_ngheader_make_res(stream->pool, headers->status, hout); - rv = nghttp2_submit_response(session->ngh2, stream->id, - ngh->nv, ngh->nvlen, pprovider); - stream->has_response = h2_headers_are_response(headers); - session->have_written = 1; - - if (stream->initiated_on) { - ++session->pushes_submitted; + status = h2_res_create_ngheader(&ngh, stream->pool, headers); + if (status == APR_SUCCESS) { + rv = nghttp2_submit_response(session->ngh2, stream->id, + ngh->nv, ngh->nvlen, pprovider); + stream->has_response = h2_headers_are_response(headers); + session->have_written = 1; + + if (stream->initiated_on) { + ++session->pushes_submitted; + } + else { + ++session->responses_submitted; + } } else { - ++session->responses_submitted; + ap_log_cerror(APLOG_MARK, APLOG_DEBUG, status, session->c, + H2_STRM_LOG(APLOGNO(), stream, "invalid response")); + h2_stream_rst(stream, NGHTTP2_PROTOCOL_ERROR); } } |