@@ -13,6 +13,8 @@ use strict;
13
13
14
14
use Test::More;
15
15
16
+ use Socket qw/ CRLF / ;
17
+
16
18
BEGIN { use FindBin; chdir ($FindBin::Bin ); }
17
19
18
20
use lib ' lib' ;
@@ -28,8 +30,8 @@ plan(skip_all => 'IO::Socket::SSL not installed') if $@;
28
30
eval { IO::Socket::SSL::SSL_VERIFY_NONE(); };
29
31
plan(skip_all => ' IO::Socket::SSL too old' ) if $@ ;
30
32
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 );
33
35
34
36
$t -> write_file_expand(' nginx.conf' , <<'EOF' );
35
37
@@ -78,6 +80,11 @@ http {
78
80
location /subject {
79
81
return 200 "body $ssl_client_s_dn";
80
82
}
83
+
84
+ location /body {
85
+ add_header X-Body $request_body always;
86
+ proxy_pass http://127.0.0.1:8080/;
87
+ }
81
88
}
82
89
83
90
server {
@@ -239,6 +246,11 @@ like(get('/protocol', 8085), qr/^body (TLS|SSL)v(\d|\.)+$/m, 'protocol');
239
246
like(cert(' /issuer' , 8085), qr ! ^body CN=issuer$ ! m , ' issuer' );
240
247
like(cert(' /subject' , 8085), qr ! ^body CN=subject$ ! m , ' subject' );
241
248
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
+
242
254
# ##############################################################################
243
255
244
256
sub get {
@@ -249,6 +261,21 @@ sub get {
249
261
return $r ;
250
262
}
251
263
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
+
252
279
sub cert {
253
280
my ($uri , $port ) = @_ ;
254
281
my $s = get_ssl_socket(undef , port($port ),
0 commit comments