From 4d2d1017d7612d6f8dc57109eebd46cac76d61e2 Mon Sep 17 00:00:00 2001 From: Stefan Eissing Date: Wed, 24 Aug 2016 14:44:53 +0000 Subject: [PATCH] mod_http2: latest h2/state debug draft, fixes in 100-continue response generation git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1757534 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES | 4 ++++ modules/http2/h2_filter.c | 2 ++ modules/http2/h2_response.c | 2 +- modules/http2/h2_stream.c | 1 + modules/http2/h2_stream.h | 1 + modules/http2/h2_task.c | 4 ++-- 6 files changed, 11 insertions(+), 3 deletions(-) diff --git a/CHANGES b/CHANGES index b646303dad..e3d29430e1 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,10 @@ -*- coding: utf-8 -*- Changes with Apache 2.5.0 + *) mod_http2: h2 status resource follows latest draft, see + http://www.ietf.org/id/draft-benfield-http2-debug-state-01.txt + [Stefan Eissing] + *) mod_http2: handling graceful shutdown gracefully, e.g. handling existing streams to the end. [Stefan Eissing] diff --git a/modules/http2/h2_filter.c b/modules/http2/h2_filter.c index 4a1b33df75..ce94b52ed6 100644 --- a/modules/http2/h2_filter.c +++ b/modules/http2/h2_filter.c @@ -258,6 +258,7 @@ static int add_stream(h2_stream *stream, void *ctx) flowOut = nghttp2_session_get_stream_remote_window_size(x->s->ngh2, stream->id); bbout(x->bb, "%s\n \"%d\": {\n", (x->idx? "," : ""), stream->id); bbout(x->bb, " \"state\": \"%s\",\n", h2_stream_state_str(stream)); + bbout(x->bb, " \"created\": %f,\n", ((double)stream->created)/APR_USEC_PER_SEC); bbout(x->bb, " \"flowIn\": %d,\n", flowIn); bbout(x->bb, " \"flowOut\": %d,\n", flowOut); bbout(x->bb, " \"dataIn\": %"APR_UINT64_T_FMT",\n", stream->in_data_octets); @@ -363,6 +364,7 @@ static apr_status_t h2_status_stream_filter(h2_stream *stream) apr_itoa(stream->pool, connFlowOut)); bbout(bb, "{\n"); + bbout(bb, " \"version\": \"draft-01\",\n"); add_settings(bb, s, 0); add_peer_settings(bb, s, 0); bbout(bb, " \"connFlowIn\": %d,\n", connFlowIn); diff --git a/modules/http2/h2_response.c b/modules/http2/h2_response.c index 80d8b031e6..792e7e57e0 100644 --- a/modules/http2/h2_response.c +++ b/modules/http2/h2_response.c @@ -144,7 +144,7 @@ h2_response *h2_response_rcreate(int stream_id, request_rec *r, int status, response->stream_id = stream_id; response->http_status = status; response->content_length = -1; - response->headers = header; + response->headers = header? header : apr_table_make(pool, 5); response->sos_filter = get_sos_filter(r->notes); check_clen(response, r, pool); diff --git a/modules/http2/h2_stream.c b/modules/http2/h2_stream.c index a3999ae75a..9b4c017567 100644 --- a/modules/http2/h2_stream.c +++ b/modules/http2/h2_stream.c @@ -181,6 +181,7 @@ h2_stream *h2_stream_open(int id, apr_pool_t *pool, h2_session *session, h2_stream *stream = apr_pcalloc(pool, sizeof(h2_stream)); stream->id = id; + stream->created = apr_time_now(); stream->state = H2_STREAM_ST_IDLE; stream->pool = pool; stream->session = session; diff --git a/modules/http2/h2_stream.h b/modules/http2/h2_stream.h index 663221c8fe..7edfae754a 100644 --- a/modules/http2/h2_stream.h +++ b/modules/http2/h2_stream.h @@ -43,6 +43,7 @@ typedef struct h2_stream h2_stream; struct h2_stream { int id; /* http2 stream id */ + apr_time_t created; /* when stream was created */ h2_stream_state_t state; /* http/2 state of this stream */ struct h2_session *session; /* the session this stream belongs to */ diff --git a/modules/http2/h2_task.c b/modules/http2/h2_task.c index daca5f1885..75f376cf0f 100644 --- a/modules/http2/h2_task.c +++ b/modules/http2/h2_task.c @@ -520,11 +520,11 @@ static apr_status_t h2_filter_continue(ap_filter_t* f, apr_status_t status; AP_DEBUG_ASSERT(task); - if (f->r->expecting_100) { + if (f->r->expecting_100 && ap_is_HTTP_SUCCESS(f->r->status)) { h2_response *response; response = h2_response_rcreate(task->stream_id, f->r, HTTP_CONTINUE, - f->r->headers_out, f->r->pool); + NULL, f->r->pool); ap_log_rerror(APLOG_MARK, APLOG_TRACE1, 0, f->r, "h2_task(%s): send 100 Continue", task->id); status = open_response(task, response); -- 2.40.0