Re: [PATCH] Proxy: support variables for proxy_method directive

2016-10-28 Thread Dmitry Lazurkin
Hello, Maxim.

On 10/26/2016 08:38 PM, Maxim Dounin wrote:
> Such a test will fail on versions without variables support in 
> proxy_method.  This is a problem, as the same test suite is used 
> to test both mainline and stable.  To address this we use 
> conditional TODO tests with version checked:
>
> diff --git a/proxy_method.t b/proxy_method.t
> --- a/proxy_method.t
> +++ b/proxy_method.t
> @@ -77,9 +77,14 @@ like(http_get('/preserve'), qr/request_m
>  like(http_get('/const'), qr/request_method=POST/,
>   'proxy_method from constant');
>  
> +TODO: {
> +local $TODO = 'not yet' unless $t->has_version('1.11.6');
> +
>  like(http_get('/var?method=POST'), qr/request_method=POST/,
>   'proxy_method from variable');
>  
> +}
> +
>  like(http_get('/parent/child'), qr/request_method=POST/,
>   'proxy_method from parent');
>
> Additionally, style is slighly different in our test scripts for 
> historical reasons, tabs are used to indent perl code.
>  
> Committed with the above changes, thanks.
>
Sorry for indentation with spaces. I will be more careful.

Thanks.


___
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel


Re: [PATCH] [PATCH] Proxy: support variables for proxy_method directive

2016-10-28 Thread Dmitry Lazurkin
Hello, Maxim.

Thank you! (:

On 10/26/2016 08:32 PM, Maxim Dounin wrote:
> Hello!
>
> On Sat, Oct 22, 2016 at 12:31:16AM +0300, dila...@gmail.com wrote:
>
>> # HG changeset patch
>> # User Dmitry Lazurkin 
>> # Date 1476631441 -10800
>> #  Sun Oct 16 18:24:01 2016 +0300
>> # Node ID 9fbfc0ccb28e1eee624ff212de88fa1c051f09d9
>> # Parent  56d6bfe6b609c565a9f500bde573fd9b488ff960
>> Proxy: support variables for proxy_method directive.
>>
>> diff -r 56d6bfe6b609 -r 9fbfc0ccb28e src/http/modules/ngx_http_proxy_module.c
>> --- a/src/http/modules/ngx_http_proxy_module.c   Fri Oct 21 16:28:39 
>> 2016 +0300
>> +++ b/src/http/modules/ngx_http_proxy_module.c   Sun Oct 16 18:24:01 
>> 2016 +0300
>> @@ -73,7 +73,7 @@
>>  ngx_array_t   *cookie_domains;
>>  ngx_array_t   *cookie_paths;
>>  
>> -ngx_str_t  method;
>> +ngx_http_complex_value_t  *method;
>>  ngx_str_t  location;
>>  ngx_str_t  url;
>>  
>> @@ -380,7 +380,7 @@
>>  
>>  { ngx_string("proxy_method"),
>>NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
>> -  ngx_conf_set_str_slot,
>> +  ngx_http_set_complex_value_slot,
>>NGX_HTTP_LOC_CONF_OFFSET,
>>offsetof(ngx_http_proxy_loc_conf_t, method),
>>NULL },
>> @@ -1159,8 +1159,10 @@
>>  /* HEAD was changed to GET to cache response */
>>  method = u->method;
>>  
>> -} else if (plcf->method.len) {
>> -method = plcf->method;
>> +} else if (plcf->method != NULL) {
>> +if (ngx_http_complex_value(r, plcf->method, &method) != NGX_OK) {
>> +return NGX_ERROR;
>> +}
>>  
>>  } else {
>>  method = r->method_name;
>> @@ -3158,7 +3160,9 @@
>>  
>>  #endif
>>  
>> -ngx_conf_merge_str_value(conf->method, prev->method, "");
>> +if (conf->method == NULL) {
>> +conf->method = prev->method;
>> +}
>>  
>>  ngx_conf_merge_value(conf->upstream.pass_request_headers,
>>prev->upstream.pass_request_headers, 1);
> Looks good, except a few style nits:
>
> - We don't usually check pointers with "!= NULL", just testing 
>   "if (plcf->method)" would be enough here.
>
> - You've forgot to update the "set by ngx_pcalloc()" comment in 
>   ngx_http_proxy_create_loc_conf().
>
> Committed with the following patch on top:
>
> --- a/src/http/modules/ngx_http_proxy_module.c
> +++ b/src/http/modules/ngx_http_proxy_module.c
> @@ -1159,7 +1159,7 @@ ngx_http_proxy_create_request(ngx_http_r
>  /* HEAD was changed to GET to cache response */
>  method = u->method;
>  
> -} else if (plcf->method != NULL) {
> +} else if (plcf->method) {
>  if (ngx_http_complex_value(r, plcf->method, &method) != NGX_OK) {
>  return NGX_ERROR;
>  }
> @@ -2799,7 +2799,7 @@ ngx_http_proxy_create_loc_conf(ngx_conf_
>   * conf->upstream.store_values = NULL;
>   * conf->upstream.ssl_name = NULL;
>   *
> - * conf->method = { 0, NULL };
> + * conf->method = NULL;
>   * conf->headers_source = NULL;
>   * conf->headers.lengths = NULL;
>   * conf->headers.values = NULL;
>
> Thanks!
>


___
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel


Re: [PATCH] Proxy: support variables for proxy_method directive

2016-10-26 Thread Maxim Dounin
Hello!

On Fri, Oct 21, 2016 at 11:53:11PM +0300, Dmitry Lazurkin wrote:

> Add more tests.
> 
> # HG changeset patch
> # User Dmitry Lazurkin 
> # Date 1476632999 -10800
> #  Sun Oct 16 18:49:59 2016 +0300
> # Node ID 916ac83eed31a4e7f6f303e28867b925fc62bc27
> # Parent  1b11a12be17913a75e81d318dcb6b912eac5f29e
> Tests: add tests for proxy_method directive.
> 
> diff -r 1b11a12be179 -r 916ac83eed31 proxy_method.t
> --- /dev/nullThu Jan 01 00:00:00 1970 +
> +++ b/proxy_method.tSun Oct 16 18:49:59 2016 +0300
> @@ -0,0 +1,86 @@
> +#!/usr/bin/perl
> +
> +# (C) Dmitry Lazurkin
> +
> +# Tests for proxy_method.
> +
> +###
> +
> +use warnings;
> +use strict;
> +
> +use Test::More;
> +
> +BEGIN { use FindBin; chdir($FindBin::Bin); }
> +
> +use lib 'lib';
> +use Test::Nginx;
> +
> +###
> +
> +select STDERR; $| = 1;
> +select STDOUT; $| = 1;
> +
> +my $t = Test::Nginx->new()->has(qw/http proxy/)->plan(4)
> +->write_file_expand('nginx.conf', <<'EOF');
> +
> +%%TEST_GLOBALS%%
> +
> +daemon off;
> +
> +events {
> +}
> +
> +http {
> +%%TEST_GLOBALS_HTTP%%
> +
> +server {
> +listen   127.0.0.1:8080;
> +server_name  localhost;
> +
> +location /preserve {
> +proxy_pass http://127.0.0.1:8080/get-method;
> +}
> +
> +location /const {
> +proxy_pass http://127.0.0.1:8080/get-method;
> +proxy_method POST;
> +}
> +
> +location /var {
> +proxy_pass http://127.0.0.1:8080/get-method;
> +proxy_method $arg_method;
> +}
> +
> +location /parent {
> +proxy_method POST;
> +location /parent/child {
> +proxy_pass http://127.0.0.1:8080/get-method;
> +}
> +}
> +
> +location /get-method {
> +return 200 "request_method=$request_method";
> +}
> +}
> +}
> +
> +EOF
> +
> +$t->run();
> +
> +###
> +
> +like(http_get('/preserve'), qr/request_method=GET/,
> + 'proxy_method from request');
> +
> +like(http_get('/const'), qr/request_method=POST/,
> + 'proxy_method from constant');
> +
> +like(http_get('/var?method=POST'), qr/request_method=POST/,
> + 'proxy_method from variable');
> +
> +like(http_get('/parent/child'), qr/request_method=POST/,
> + 'proxy_method from parent');
> +
> +###

Such a test will fail on versions without variables support in 
proxy_method.  This is a problem, as the same test suite is used 
to test both mainline and stable.  To address this we use 
conditional TODO tests with version checked:

diff --git a/proxy_method.t b/proxy_method.t
--- a/proxy_method.t
+++ b/proxy_method.t
@@ -77,9 +77,14 @@ like(http_get('/preserve'), qr/request_m
 like(http_get('/const'), qr/request_method=POST/,
  'proxy_method from constant');
 
+TODO: {
+local $TODO = 'not yet' unless $t->has_version('1.11.6');
+
 like(http_get('/var?method=POST'), qr/request_method=POST/,
  'proxy_method from variable');
 
+}
+
 like(http_get('/parent/child'), qr/request_method=POST/,
  'proxy_method from parent');

Additionally, style is slighly different in our test scripts for 
historical reasons, tabs are used to indent perl code.
 
Committed with the above changes, thanks.

-- 
Maxim Dounin
http://nginx.org/

___
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel


Re: [PATCH] [PATCH] Proxy: support variables for proxy_method directive

2016-10-26 Thread Maxim Dounin
Hello!

On Sat, Oct 22, 2016 at 12:31:16AM +0300, dila...@gmail.com wrote:

> # HG changeset patch
> # User Dmitry Lazurkin 
> # Date 1476631441 -10800
> #  Sun Oct 16 18:24:01 2016 +0300
> # Node ID 9fbfc0ccb28e1eee624ff212de88fa1c051f09d9
> # Parent  56d6bfe6b609c565a9f500bde573fd9b488ff960
> Proxy: support variables for proxy_method directive.
> 
> diff -r 56d6bfe6b609 -r 9fbfc0ccb28e src/http/modules/ngx_http_proxy_module.c
> --- a/src/http/modules/ngx_http_proxy_module.cFri Oct 21 16:28:39 
> 2016 +0300
> +++ b/src/http/modules/ngx_http_proxy_module.cSun Oct 16 18:24:01 
> 2016 +0300
> @@ -73,7 +73,7 @@
>  ngx_array_t   *cookie_domains;
>  ngx_array_t   *cookie_paths;
>  
> -ngx_str_t  method;
> +ngx_http_complex_value_t  *method;
>  ngx_str_t  location;
>  ngx_str_t  url;
>  
> @@ -380,7 +380,7 @@
>  
>  { ngx_string("proxy_method"),
>NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
> -  ngx_conf_set_str_slot,
> +  ngx_http_set_complex_value_slot,
>NGX_HTTP_LOC_CONF_OFFSET,
>offsetof(ngx_http_proxy_loc_conf_t, method),
>NULL },
> @@ -1159,8 +1159,10 @@
>  /* HEAD was changed to GET to cache response */
>  method = u->method;
>  
> -} else if (plcf->method.len) {
> -method = plcf->method;
> +} else if (plcf->method != NULL) {
> +if (ngx_http_complex_value(r, plcf->method, &method) != NGX_OK) {
> +return NGX_ERROR;
> +}
>  
>  } else {
>  method = r->method_name;
> @@ -3158,7 +3160,9 @@
>  
>  #endif
>  
> -ngx_conf_merge_str_value(conf->method, prev->method, "");
> +if (conf->method == NULL) {
> +conf->method = prev->method;
> +}
>  
>  ngx_conf_merge_value(conf->upstream.pass_request_headers,
>prev->upstream.pass_request_headers, 1);

Looks good, except a few style nits:

- We don't usually check pointers with "!= NULL", just testing 
  "if (plcf->method)" would be enough here.

- You've forgot to update the "set by ngx_pcalloc()" comment in 
  ngx_http_proxy_create_loc_conf().

Committed with the following patch on top:

--- a/src/http/modules/ngx_http_proxy_module.c
+++ b/src/http/modules/ngx_http_proxy_module.c
@@ -1159,7 +1159,7 @@ ngx_http_proxy_create_request(ngx_http_r
 /* HEAD was changed to GET to cache response */
 method = u->method;
 
-} else if (plcf->method != NULL) {
+} else if (plcf->method) {
 if (ngx_http_complex_value(r, plcf->method, &method) != NGX_OK) {
 return NGX_ERROR;
 }
@@ -2799,7 +2799,7 @@ ngx_http_proxy_create_loc_conf(ngx_conf_
  * conf->upstream.store_values = NULL;
  * conf->upstream.ssl_name = NULL;
  *
- * conf->method = { 0, NULL };
+ * conf->method = NULL;
  * conf->headers_source = NULL;
  * conf->headers.lengths = NULL;
  * conf->headers.values = NULL;

Thanks!

-- 
Maxim Dounin
http://nginx.org/

___
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel


[PATCH] [PATCH] Proxy: support variables for proxy_method directive

2016-10-21 Thread dilaz03
# HG changeset patch
# User Dmitry Lazurkin 
# Date 1476631441 -10800
#  Sun Oct 16 18:24:01 2016 +0300
# Node ID 9fbfc0ccb28e1eee624ff212de88fa1c051f09d9
# Parent  56d6bfe6b609c565a9f500bde573fd9b488ff960
Proxy: support variables for proxy_method directive.

diff -r 56d6bfe6b609 -r 9fbfc0ccb28e src/http/modules/ngx_http_proxy_module.c
--- a/src/http/modules/ngx_http_proxy_module.c  Fri Oct 21 16:28:39 2016 +0300
+++ b/src/http/modules/ngx_http_proxy_module.c  Sun Oct 16 18:24:01 2016 +0300
@@ -73,7 +73,7 @@
 ngx_array_t   *cookie_domains;
 ngx_array_t   *cookie_paths;
 
-ngx_str_t  method;
+ngx_http_complex_value_t  *method;
 ngx_str_t  location;
 ngx_str_t  url;
 
@@ -380,7 +380,7 @@
 
 { ngx_string("proxy_method"),
   NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
-  ngx_conf_set_str_slot,
+  ngx_http_set_complex_value_slot,
   NGX_HTTP_LOC_CONF_OFFSET,
   offsetof(ngx_http_proxy_loc_conf_t, method),
   NULL },
@@ -1159,8 +1159,10 @@
 /* HEAD was changed to GET to cache response */
 method = u->method;
 
-} else if (plcf->method.len) {
-method = plcf->method;
+} else if (plcf->method != NULL) {
+if (ngx_http_complex_value(r, plcf->method, &method) != NGX_OK) {
+return NGX_ERROR;
+}
 
 } else {
 method = r->method_name;
@@ -3158,7 +3160,9 @@
 
 #endif
 
-ngx_conf_merge_str_value(conf->method, prev->method, "");
+if (conf->method == NULL) {
+conf->method = prev->method;
+}
 
 ngx_conf_merge_value(conf->upstream.pass_request_headers,
   prev->upstream.pass_request_headers, 1);

___
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel


[PATCH] Proxy: support variables for proxy_method directive

2016-10-21 Thread Dmitry Lazurkin
Formatting of previous patch was corrupted. Sorry for another message. I 
don't known how to correct work with mailing list. I try to set fixed 
width for patch.


# HG changeset patch
# User Dmitry Lazurkin 
# Date 1476631441 -10800
#  Sun Oct 16 18:24:01 2016 +0300
# Node ID 9fbfc0ccb28e1eee624ff212de88fa1c051f09d9
# Parent  56d6bfe6b609c565a9f500bde573fd9b488ff960
Proxy: support variables for proxy_method directive.

diff -r 56d6bfe6b609 -r 9fbfc0ccb28e 
src/http/modules/ngx_http_proxy_module.c
--- a/src/http/modules/ngx_http_proxy_module.cFri Oct 21 16:28:39 
2016 +0300
+++ b/src/http/modules/ngx_http_proxy_module.cSun Oct 16 18:24:01 
2016 +0300

@@ -73,7 +73,7 @@
 ngx_array_t   *cookie_domains;
 ngx_array_t   *cookie_paths;

-ngx_str_t  method;
+ngx_http_complex_value_t  *method;
 ngx_str_t  location;
 ngx_str_t  url;

@@ -380,7 +380,7 @@

 { ngx_string("proxy_method"),
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
-  ngx_conf_set_str_slot,
+  ngx_http_set_complex_value_slot,
   NGX_HTTP_LOC_CONF_OFFSET,
   offsetof(ngx_http_proxy_loc_conf_t, method),
   NULL },
@@ -1159,8 +1159,10 @@
 /* HEAD was changed to GET to cache response */
 method = u->method;

-} else if (plcf->method.len) {
-method = plcf->method;
+} else if (plcf->method != NULL) {
+if (ngx_http_complex_value(r, plcf->method, &method) != NGX_OK) {
+return NGX_ERROR;
+}

 } else {
 method = r->method_name;
@@ -3158,7 +3160,9 @@

 #endif

-ngx_conf_merge_str_value(conf->method, prev->method, "");
+if (conf->method == NULL) {
+conf->method = prev->method;
+}

ngx_conf_merge_value(conf->upstream.pass_request_headers,
prev->upstream.pass_request_headers, 1);

___
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel


[PATCH] Proxy: support variables for proxy_method directive

2016-10-21 Thread Dmitry Lazurkin

Add more tests.

# HG changeset patch
# User Dmitry Lazurkin 
# Date 1476632999 -10800
#  Sun Oct 16 18:49:59 2016 +0300
# Node ID 916ac83eed31a4e7f6f303e28867b925fc62bc27
# Parent  1b11a12be17913a75e81d318dcb6b912eac5f29e
Tests: add tests for proxy_method directive.

diff -r 1b11a12be179 -r 916ac83eed31 proxy_method.t
--- /dev/nullThu Jan 01 00:00:00 1970 +
+++ b/proxy_method.tSun Oct 16 18:49:59 2016 +0300
@@ -0,0 +1,86 @@
+#!/usr/bin/perl
+
+# (C) Dmitry Lazurkin
+
+# Tests for proxy_method.
+
+###
+
+use warnings;
+use strict;
+
+use Test::More;
+
+BEGIN { use FindBin; chdir($FindBin::Bin); }
+
+use lib 'lib';
+use Test::Nginx;
+
+###
+
+select STDERR; $| = 1;
+select STDOUT; $| = 1;
+
+my $t = Test::Nginx->new()->has(qw/http proxy/)->plan(4)
+->write_file_expand('nginx.conf', <<'EOF');
+
+%%TEST_GLOBALS%%
+
+daemon off;
+
+events {
+}
+
+http {
+%%TEST_GLOBALS_HTTP%%
+
+server {
+listen   127.0.0.1:8080;
+server_name  localhost;
+
+location /preserve {
+proxy_pass http://127.0.0.1:8080/get-method;
+}
+
+location /const {
+proxy_pass http://127.0.0.1:8080/get-method;
+proxy_method POST;
+}
+
+location /var {
+proxy_pass http://127.0.0.1:8080/get-method;
+proxy_method $arg_method;
+}
+
+location /parent {
+proxy_method POST;
+location /parent/child {
+proxy_pass http://127.0.0.1:8080/get-method;
+}
+}
+
+location /get-method {
+return 200 "request_method=$request_method";
+}
+}
+}
+
+EOF
+
+$t->run();
+
+###
+
+like(http_get('/preserve'), qr/request_method=GET/,
+ 'proxy_method from request');
+
+like(http_get('/const'), qr/request_method=POST/,
+ 'proxy_method from constant');
+
+like(http_get('/var?method=POST'), qr/request_method=POST/,
+ 'proxy_method from variable');
+
+like(http_get('/parent/child'), qr/request_method=POST/,
+ 'proxy_method from parent');
+
+###

___
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel


[PATCH] Proxy: support variables for proxy_method directive

2016-10-21 Thread Dmitry Lazurkin

Hello,

I refactor solution with ngx_http_set_complex_value_slot.

# HG changeset patch
# User Dmitry Lazurkin 
# Date 1476631441 -10800
#  Sun Oct 16 18:24:01 2016 +0300
# Node ID 9fbfc0ccb28e1eee624ff212de88fa1c051f09d9
# Parent  56d6bfe6b609c565a9f500bde573fd9b488ff960
Proxy: support variables for proxy_method directive.

diff -r 56d6bfe6b609 -r 9fbfc0ccb28e 
src/http/modules/ngx_http_proxy_module.c
--- a/src/http/modules/ngx_http_proxy_module.cFri Oct 21 16:28:39 
2016 +0300
+++ b/src/http/modules/ngx_http_proxy_module.cSun Oct 16 18:24:01 
2016 +0300

@@ -73,7 +73,7 @@
 ngx_array_t   *cookie_domains;
 ngx_array_t   *cookie_paths;

-ngx_str_t  method;
+ngx_http_complex_value_t  *method;
 ngx_str_t  location;
 ngx_str_t  url;

@@ -380,7 +380,7 @@

 { ngx_string("proxy_method"),
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
-  ngx_conf_set_str_slot,
+  ngx_http_set_complex_value_slot,
   NGX_HTTP_LOC_CONF_OFFSET,
   offsetof(ngx_http_proxy_loc_conf_t, method),
   NULL },
@@ -1159,8 +1159,10 @@
 /* HEAD was changed to GET to cache response */
 method = u->method;

-} else if (plcf->method.len) {
-method = plcf->method;
+} else if (plcf->method != NULL) {
+if (ngx_http_complex_value(r, plcf->method, &method) != NGX_OK) {
+return NGX_ERROR;
+}

 } else {
 method = r->method_name;
@@ -3158,7 +3160,9 @@

 #endif

-ngx_conf_merge_str_value(conf->method, prev->method, "");
+if (conf->method == NULL) {
+conf->method = prev->method;
+}

 ngx_conf_merge_value(conf->upstream.pass_request_headers,
prev->upstream.pass_request_headers, 1);


___
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel


Re: [PATCH] Proxy: support variables for proxy_method directive

2016-10-21 Thread Dmitry Lazurkin

Ticket on issue tracker with my comment:

https://trac.nginx.org/nginx/ticket/283


___
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel


[PATCH] Proxy: support variables for proxy_method directive

2016-10-17 Thread Dmitry Lazurkin
# HG changeset patch
# User Dmitry Lazurkin 
# Date 1476631441 -10800
#  Sun Oct 16 18:24:01 2016 +0300
# Node ID b8d4a355e3ce2e47eff9424b432a22a4c86d9f08
# Parent  20eb4587225b3d7849ec5ece5732ed261226d365
Proxy: support variables for proxy_method directive.

diff -r 20eb4587225b -r b8d4a355e3ce src/http/modules/ngx_http_proxy_module.c
--- a/src/http/modules/ngx_http_proxy_module.c  Fri Oct 14 19:48:26 2016 +0300
+++ b/src/http/modules/ngx_http_proxy_module.c  Sun Oct 16 18:24:01 2016 +0300
@@ -73,7 +73,7 @@
 ngx_array_t   *cookie_domains;
 ngx_array_t   *cookie_paths;
 
-ngx_str_t  method;
+ngx_http_complex_value_t   method;
 ngx_str_t  location;
 ngx_str_t  url;
 
@@ -182,6 +182,8 @@
 void *conf);
 static char *ngx_http_proxy_store(ngx_conf_t *cf, ngx_command_t *cmd,
 void *conf);
+static char *ngx_http_proxy_method(ngx_conf_t *cf, ngx_command_t *cmd,
+void *conf);
 #if (NGX_HTTP_CACHE)
 static char *ngx_http_proxy_cache(ngx_conf_t *cf, ngx_command_t *cmd,
 void *conf);
@@ -380,9 +382,9 @@
 
 { ngx_string("proxy_method"),
   NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
-  ngx_conf_set_str_slot,
+  ngx_http_proxy_method,
   NGX_HTTP_LOC_CONF_OFFSET,
-  offsetof(ngx_http_proxy_loc_conf_t, method),
+  0,
   NULL },
 
 { ngx_string("proxy_pass_request_headers"),
@@ -1159,8 +1161,10 @@
 /* HEAD was changed to GET to cache response */
 method = u->method;
 
-} else if (plcf->method.len) {
-method = plcf->method;
+} else if (plcf->method.value.data) {
+if (ngx_http_complex_value(r, &plcf->method, &method) != NGX_OK) {
+return NGX_ERROR;
+}
 
 } else {
 method = r->method_name;
@@ -3158,7 +3162,9 @@
 
 #endif
 
-ngx_conf_merge_str_value(conf->method, prev->method, "");
+if (conf->method.value.data == NULL) {
+conf->method = prev->method;
+}
 
 ngx_conf_merge_value(conf->upstream.pass_request_headers,
   prev->upstream.pass_request_headers, 1);
@@ -4140,6 +4146,34 @@
 }
 
 
+static char *
+ngx_http_proxy_method(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
+{
+ngx_http_proxy_loc_conf_t *plcf = conf;
+
+ngx_str_t *value;
+ngx_http_compile_complex_value_t   ccv;
+
+value = cf->args->elts;
+
+if (plcf->method.value.data) {
+return "is duplicate";
+}
+
+ngx_memzero(&ccv, sizeof(ngx_http_compile_complex_value_t));
+
+ccv.cf = cf;
+ccv.value = &value[1];
+ccv.complex_value = &plcf->method;
+
+if (ngx_http_compile_complex_value(&ccv) != NGX_OK) {
+return NGX_CONF_ERROR;
+}
+
+return NGX_CONF_OK;
+}
+
+
 #if (NGX_HTTP_CACHE)
 
 static char *

___
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel