changeset 1325:f80176242a7e

Tests: c->read->ready handling in ngx_ssl_recv(), fixed in 1.5.8.
author Sergey Kandaurov <pluknet@nginx.com>
date Thu, 17 May 2018 15:43:08 +0300
parents 918bf90466e0
children fda0bf1cc601
files ssl.t
diffstat 1 files changed, 29 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- 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),