# HG changeset patch # User Sergey Kandaurov # Date 1507816514 -10800 # Node ID a79bf84726af77abab72e381f828234f71289a28 # Parent 124322e9accd46d0ca27da426b568b7c41e26327 Tests: connection upgrade in subrequests. diff --git a/proxy_upgrade.t b/proxy_upgrade.t --- 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', ' 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;