]> git.kaiwu.me - nginx.git/commitdiff
Proxy: fixed proxy_method to always add space.
authorMaxim Dounin <mdounin@mdounin.ru>
Tue, 22 Jan 2013 12:36:00 +0000 (12:36 +0000)
committerMaxim Dounin <mdounin@mdounin.ru>
Tue, 22 Jan 2013 12:36:00 +0000 (12:36 +0000)
Before the patch if proxy_method was specified at http{} level the code
to add trailing space wasn't executed, resulting in incorrect requests
to upstream.

src/http/modules/ngx_http_proxy_module.c

index a8265732ff0052f4b18f875ee3568921ab12a299..ce47a9e34df9fae9b18a456ae320c24a682e5b3d 100644 (file)
@@ -2353,7 +2353,7 @@ ngx_http_proxy_create_loc_conf(ngx_conf_t *cf)
      *     conf->upstream.store_lengths = NULL;
      *     conf->upstream.store_values = NULL;
      *
-     *     conf->method = NULL;
+     *     conf->method = { 0, NULL };
      *     conf->headers_source = NULL;
      *     conf->headers_set_len = NULL;
      *     conf->headers_set = NULL;
@@ -2657,10 +2657,11 @@ ngx_http_proxy_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
 
 #endif
 
-    if (conf->method.len == 0) {
-        conf->method = prev->method;
+    ngx_conf_merge_str_value(conf->method, prev->method, "");
 
-    } else {
+    if (conf->method.len
+        && conf->method.data[conf->method.len - 1] != ' ')
+    {
         conf->method.data[conf->method.len] = ' ';
         conf->method.len++;
     }