Tests: c->read->ready handling in ngx_ssl_recv(), fixed in 1.5.8.
diff --git a/ssl.t b/ssl.t
index aa75dbb..cc1dc5f 100644
--- a/ssl.t
+++ b/ssl.t
@@ -13,6 +13,8 @@
use Test::More;
+use Socket qw/ CRLF /;
+
BEGIN { use FindBin; chdir($FindBin::Bin); }
use lib 'lib';
@@ -28,8 +30,8 @@
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 @@
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(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 @@
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),