Welcome! Log In Create A New Profile

Advanced

[PATCH] Proxy: support variables for proxy_method directive

Dmitry Lazurkin
October 21, 2016 04:54PM
Add more tests.

# HG changeset patch
# User Dmitry Lazurkin <dilaz03@gmail.com>
# 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/null Thu Jan 01 00:00:00 1970 +0000
+++ b/proxy_method.t Sun 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
Subject Author Views Posted

[PATCH] Proxy: support variables for proxy_method directive

Dmitry Lazurkin 632 October 21, 2016 04:54PM

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

Maxim Dounin 294 October 26, 2016 01:40PM

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

Dmitry Lazurkin 295 October 28, 2016 09:18AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 309
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready