From: Stefan Eissing Date: Mon, 26 Oct 2015 12:15:43 +0000 (+0000) Subject: first request on master connection only reports more preferred protocols in Upgrade... X-Git-Tag: 2.5.0-alpha~2690 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5b5c48e6572a1949a3da09b8ff57d66f74d09919;p=thirdparty%2Fapache%2Fhttpd.git first request on master connection only reports more preferred protocols in Upgrade header git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1710583 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/include/http_protocol.h b/include/http_protocol.h index 20e1b782e74..34d62ad29af 100644 --- a/include/http_protocol.h +++ b/include/http_protocol.h @@ -788,14 +788,19 @@ AP_DECLARE_HOOK(const char *,protocol_get,(const conn_rec *c)) * upgrade to - besides the protocol currently active on the connection. These * values may be used to announce to a client what choices it has. * + * If report_all == 0, only protocols more preferable than the one currently + * being used, are reported. Otherwise, all available protocols beside the + * current one are being reported. + * * @param c The current connection * @param r The current request or NULL * @param s The server/virtual host selected or NULL + * @param report_all include also protocols less preferred than the current one * @param pupgrades on return, possible protocols to upgrade to in descending order * of preference. Maybe NULL if none are available. */ AP_DECLARE(apr_status_t) ap_get_protocol_upgrades(conn_rec *c, request_rec *r, - server_rec *s, + server_rec *s, int report_all, const apr_array_header_t **pupgrades); /** diff --git a/server/core.c b/server/core.c index de1c19c8358..5602e5730a2 100644 --- a/server/core.c +++ b/server/core.c @@ -5392,7 +5392,7 @@ static int core_upgrade_handler(request_rec *r) * client. If the client is already talking a protocol with requests * on slave connections, leave it be. */ const apr_array_header_t *upgrades; - ap_get_protocol_upgrades(c, r, NULL, &upgrades); + ap_get_protocol_upgrades(c, r, NULL, 0, &upgrades); if (upgrades && upgrades->nelts > 0) { char *protocols = apr_array_pstrcat(r->pool, upgrades, ','); apr_table_setn(r->headers_out, "Upgrade", protocols); diff --git a/server/protocol.c b/server/protocol.c index f8b9b103a45..810d3b056be 100644 --- a/server/protocol.c +++ b/server/protocol.c @@ -1983,7 +1983,7 @@ AP_DECLARE(const char *) ap_get_protocol(conn_rec *c) } AP_DECLARE(apr_status_t) ap_get_protocol_upgrades(conn_rec *c, request_rec *r, - server_rec *s, + server_rec *s, int report_all, const apr_array_header_t **pupgrades) { apr_pool_t *pool = r? r->pool : c->pool; @@ -2012,6 +2012,9 @@ AP_DECLARE(apr_status_t) ap_get_protocol_upgrades(conn_rec *c, request_rec *r, /* not the one we have and possible, add in this order */ APR_ARRAY_PUSH(upgrades, const char*) = p; } + else if (!report_all) { + break; + } } } }