Skip to content

Commit 61aa3ec

Browse files
committed
Tests: c->read->ready handling in ngx_ssl_recv(), fixed in 1.5.8.
1 parent a1da759 commit 61aa3ec

File tree

1 file changed

+29
-2
lines changed

1 file changed

+29
-2
lines changed

ssl.t

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ use strict;
1313

1414
use Test::More;
1515

16+
use Socket qw/ CRLF /;
17+
1618
BEGIN { use FindBin; chdir($FindBin::Bin); }
1719

1820
use lib 'lib';
@@ -28,8 +30,8 @@ plan(skip_all => 'IO::Socket::SSL not installed') if $@;
2830
eval { IO::Socket::SSL::SSL_VERIFY_NONE(); };
2931
plan(skip_all => 'IO::Socket::SSL too old') if $@;
3032

31-
my $t = Test::Nginx->new()->has(qw/http http_ssl rewrite/)
32-
->has_daemon('openssl')->plan(20);
33+
my $t = Test::Nginx->new()->has(qw/http http_ssl rewrite proxy/)
34+
->has_daemon('openssl')->plan(21);
3335

3436
$t->write_file_expand('nginx.conf', <<'EOF');
3537
@@ -78,6 +80,11 @@ http {
7880
location /subject {
7981
return 200 "body $ssl_client_s_dn";
8082
}
83+
84+
location /body {
85+
add_header X-Body $request_body always;
86+
proxy_pass http://127.0.0.1:8080/;
87+
}
8188
}
8289
8390
server {
@@ -239,6 +246,11 @@ like(get('/protocol', 8085), qr/^body (TLS|SSL)v(\d|\.)+$/m, 'protocol');
239246
like(cert('/issuer', 8085), qr!^body CN=issuer$!m, 'issuer');
240247
like(cert('/subject', 8085), qr!^body CN=subject$!m, 'subject');
241248

249+
# c->read->ready handling bug in ngx_ssl_recv(), triggered with chunked body
250+
251+
like(get_body('/body', '0123456789', 20, 5), qr/X-Body: (0123456789){100}/,
252+
'request body chunked');
253+
242254
###############################################################################
243255

244256
sub get {
@@ -249,6 +261,21 @@ sub get {
249261
return $r;
250262
}
251263

264+
sub get_body {
265+
my ($uri, $body, $len, $n) = @_;
266+
my $s = get_ssl_socket($ctx, port(8085)) or return;
267+
http("GET /body HTTP/1.1" . CRLF
268+
. "Host: localhost" . CRLF
269+
. "Connection: close" . CRLF
270+
. "Transfer-Encoding: chunked" . CRLF . CRLF,
271+
socket => $s, start => 1);
272+
http("c8" . CRLF . $body x $len . CRLF, socket => $s, start => 1)
273+
for 1 .. $n;
274+
my $r = http("0" . CRLF . CRLF, socket => $s);
275+
$s->close();
276+
return $r;
277+
}
278+
252279
sub cert {
253280
my ($uri, $port) = @_;
254281
my $s = get_ssl_socket(undef, port($port),

0 commit comments

Comments
 (0)