changeset 1227:a79bf84726af

Tests: connection upgrade in subrequests.
author Sergey Kandaurov <pluknet@nginx.com>
date Thu, 12 Oct 2017 16:55:14 +0300
parents 124322e9accd
children 31045e639732
files proxy_upgrade.t
diffstat 1 files changed, 22 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/proxy_upgrade.t
+++ b/proxy_upgrade.t
@@ -27,8 +27,8 @@ use Test::Nginx;
 select STDERR; $| = 1;
 select STDOUT; $| = 1;
 
-my $t = Test::Nginx->new()->has(qw/http proxy/)
-	->write_file_expand('nginx.conf', <<'EOF')->plan(30);
+my $t = Test::Nginx->new()->has(qw/http proxy ssi/)
+	->write_file_expand('nginx.conf', <<'EOF')->plan(31);
 
 %%TEST_GLOBALS%%
 
@@ -55,6 +55,10 @@ http {
             proxy_read_timeout 2s;
             send_timeout 2s;
         }
+
+        location /ssi.html {
+            ssi on;
+        }
     }
 }
 
@@ -62,6 +66,8 @@ EOF
 
 my $d = $t->testdir();
 
+$t->write_file('ssi.html', '<!--#include virtual="/upgrade" --> SEE-THIS');
+
 $t->run_daemon(\&upgrade_fake_daemon);
 $t->run();
 
@@ -129,6 +135,17 @@ undef $s;
 $s = upgrade_connect(noheader => 1);
 ok(!$s, "handshake noupgrade");
 
+# connection upgrade in subrequests shouldn't cause a segfault
+
+SKIP: {
+skip 'leaves coredump', 1 unless $t->has_version('1.13.7')
+	or $ENV{TEST_NGINX_UNSAFE};
+
+$s = upgrade_connect(uri => '/ssi.html');
+ok(!$s, "handshake in subrequests");
+
+}
+
 # bytes sent on upgraded connection
 # verify with 1) data actually read by client, 2) expected data from backend
 
@@ -153,7 +170,9 @@ sub upgrade_connect {
 
 	# send request, $h->to_string
 
-	my $buf = "GET / HTTP/1.1" . CRLF
+	my $uri = $opts{uri} || '/';
+
+	my $buf = "GET $uri HTTP/1.1" . CRLF
 		. "Host: localhost" . CRLF
 		. ($opts{noheader} ? '' : "Upgrade: foo" . CRLF)
 		. "Connection: Upgrade" . CRLF . CRLF;