# HG changeset patch # User Sergey Kandaurov # Date 1526560988 -10800 # Node ID f80176242a7edf19d4c5d31352481733dd9a41b8 # Parent 918bf90466e0442772aecafee92e8f1eda4d460c Tests: c->read->ready handling in ngx_ssl_recv(), fixed in 1.5.8. diff --git a/ssl.t b/ssl.t --- a/ssl.t +++ b/ssl.t @@ -13,6 +13,8 @@ use strict; use Test::More; +use Socket qw/ CRLF /; + BEGIN { use FindBin; chdir($FindBin::Bin); } use lib 'lib'; @@ -28,8 +30,8 @@ plan(skip_all => 'IO::Socket::SSL not in eval { IO::Socket::SSL::SSL_VERIFY_NONE(); }; plan(skip_all => 'IO::Socket::SSL too old') if $@; -my $t = Test::Nginx->new()->has(qw/http http_ssl rewrite/) - ->has_daemon('openssl')->plan(20); +my $t = Test::Nginx->new()->has(qw/http http_ssl rewrite proxy/) + ->has_daemon('openssl')->plan(21); $t->write_file_expand('nginx.conf', <<'EOF'); @@ -78,6 +80,11 @@ http { location /subject { return 200 "body $ssl_client_s_dn"; } + + location /body { + add_header X-Body $request_body always; + proxy_pass http://127.0.0.1:8080/; + } } server { @@ -239,6 +246,11 @@ like(get('/protocol', 8085), qr/^body (T like(cert('/issuer', 8085), qr!^body CN=issuer$!m, 'issuer'); like(cert('/subject', 8085), qr!^body CN=subject$!m, 'subject'); +# c->read->ready handling bug in ngx_ssl_recv(), triggered with chunked body + +like(get_body('/body', '0123456789', 20, 5), qr/X-Body: (0123456789){100}/, + 'request body chunked'); + ############################################################################### sub get { @@ -249,6 +261,21 @@ sub get { return $r; } +sub get_body { + my ($uri, $body, $len, $n) = @_; + my $s = get_ssl_socket($ctx, port(8085)) or return; + http("GET /body HTTP/1.1" . CRLF + . "Host: localhost" . CRLF + . "Connection: close" . CRLF + . "Transfer-Encoding: chunked" . CRLF . CRLF, + socket => $s, start => 1); + http("c8" . CRLF . $body x $len . CRLF, socket => $s, start => 1) + for 1 .. $n; + my $r = http("0" . CRLF . CRLF, socket => $s); + $s->close(); + return $r; +} + sub cert { my ($uri, $port) = @_; my $s = get_ssl_socket(undef, port($port),