]> granicus.if.org Git - apache/commitdiff
fixes existing protocol missing in selection if not explicitly proposed
authorStefan Eissing <icing@apache.org>
Fri, 14 Aug 2015 12:16:56 +0000 (12:16 +0000)
committerStefan Eissing <icing@apache.org>
Fri, 14 Aug 2015 12:16:56 +0000 (12:16 +0000)
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1695874 13f79535-47bb-0310-9956-ffa450edef68

server/protocol.c

index 4577d23383e3e86920a3a4e820df420775d16c95..bb2951560abee95ac1b6f5e84498106a9b5ecbd3 100644 (file)
@@ -1990,7 +1990,7 @@ AP_DECLARE(const char *) ap_select_protocol(conn_rec *c, request_rec *r,
 {
     apr_pool_t *pool = r? r->pool : c->pool;
     apr_array_header_t *proposals;
-    const char *protocol = NULL;
+    const char *protocol = NULL, *existing = ap_run_protocol_get(c);
     core_server_config *conf = ap_get_core_module_config(s->module_config);
 
     if (APLOGcdebug(c)) {
@@ -2009,11 +2009,21 @@ AP_DECLARE(const char *) ap_select_protocol(conn_rec *c, request_rec *r,
         apr_array_header_t *prefs = ((conf->protocols_honor_order > 0
                                       && conf->protocols->nelts > 0)? 
                                      conf->protocols : choices);
+
+        /* If the existing protocol has not been proposed, but is a choice,
+         * add it to the proposals implicitly.
+         */
+        if (array_index(proposals, existing) < 0 
+            && array_index(choices, existing) >= 0) {
+            APR_ARRAY_PUSH(proposals, const char*) = existing;
+        }
+        
         /* Select the most preferred protocol */
         if (APLOGcdebug(c)) {
             ap_log_cerror(APLOG_MARK, APLOG_DEBUG, 0, c, 
-                          "select protocol, proposals=%s", 
-                          apr_array_pstrcat(pool, proposals, ','));
+                          "select protocol, proposals=%s preferences=%s", 
+                          apr_array_pstrcat(pool, proposals, ','),
+                          apr_array_pstrcat(pool, prefs, ','));
         }
         for (i = 0; i < proposals->nelts; ++i) {
             const char *p = APR_ARRAY_IDX(proposals, i, const char *);
@@ -2034,7 +2044,7 @@ AP_DECLARE(const char *) ap_select_protocol(conn_rec *c, request_rec *r,
                       protocol? protocol : "(none)");
     }
 
-    return protocol? protocol : ap_run_protocol_get(c);
+    return protocol? protocol : existing;
 }
 
 AP_DECLARE(apr_status_t) ap_switch_protocol(conn_rec *c, request_rec *r,