From: Stefan Eissing Date: Fri, 17 Jul 2015 14:52:11 +0000 (+0000) Subject: fix for detecting direct mode on a TLS connections X-Git-Tag: 2.5.0-alpha~3000 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c5ebe036e67551590e0f137561c7e9919e347752;p=apache fix for detecting direct mode on a TLS connections git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1691582 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/modules/http2/h2_config.h b/modules/http2/h2_config.h index e51fd276a6..1ed0e58478 100644 --- a/modules/http2/h2_config.h +++ b/modules/http2/h2_config.h @@ -59,7 +59,7 @@ typedef struct h2_config { processing, better compatibility */ int hack_mpm_event; /* If mpm_event is detected, perform a hack on stream connections to make it work */ - int h2_direct; /* if mod_h2 is active on non-TLS directly */ + int h2_direct; /* if mod_h2 is active directly */ int buffer_output; /* if output buffering shall be used */ int buffer_size; /* size of buffer for outgoing data */ int write_max; /* max number of bytes for a write op */ diff --git a/modules/http2/h2_h2.c b/modules/http2/h2_h2.c index 8bc4383f3a..5c36f3fb10 100644 --- a/modules/http2/h2_h2.c +++ b/modules/http2/h2_h2.c @@ -160,7 +160,7 @@ int h2_h2_process_conn(conn_rec* c) if (h2_ctx_pnego_is_ongoing(ctx)) { temp = apr_brigade_create(c->pool, c->bucket_alloc); ap_get_brigade(c->input_filters, temp, - AP_MODE_SPECULATIVE, APR_BLOCK_READ, 1); + AP_MODE_SPECULATIVE, APR_BLOCK_READ, 24); apr_brigade_destroy(temp); } @@ -172,15 +172,22 @@ int h2_h2_process_conn(conn_rec* c) apr_status_t status; temp = apr_brigade_create(c->pool, c->bucket_alloc); status = ap_get_brigade(c->input_filters, temp, - AP_MODE_SPECULATIVE, APR_BLOCK_READ, 24); + /*h2_h2_is_tls(c)? AP_MODE_READBYTES :*/ AP_MODE_SPECULATIVE, APR_BLOCK_READ, 24); if (status == APR_SUCCESS) { char *s = NULL; apr_size_t slen; apr_brigade_pflatten(temp, &s, &slen, c->pool); - if ((slen == 24) && !memcmp(H2_MAGIC_TOKEN, s, 24)) { + if ((slen >= 24) && !memcmp(H2_MAGIC_TOKEN, s, 24)) { + ap_log_cerror(APLOG_MARK, APLOG_TRACE1, 0, c, + "h2_h2, direct mode detected"); h2_ctx_pnego_set_done(ctx, "h2"); } + else { + ap_log_cerror(APLOG_MARK, APLOG_TRACE1, 0, c, + "h2_h2, not detected, seeing %d bytes: %s", + (int)slen, s); + } } apr_brigade_destroy(temp); }