comparison h2_request_body.t @ 1226:124322e9accd

Tests: HTTP/2 request body sync buffer test added (ticket #1384).
author Sergey Kandaurov <pluknet@nginx.com>
date Tue, 19 Sep 2017 01:45:05 +0300
parents a5e428f4440d
children a4a040b4e4dd
comparison
equal deleted inserted replaced
1225:66426ca24671 1226:124322e9accd
21 ############################################################################### 21 ###############################################################################
22 22
23 select STDERR; $| = 1; 23 select STDERR; $| = 1;
24 select STDOUT; $| = 1; 24 select STDOUT; $| = 1;
25 25
26 my $t = Test::Nginx->new()->has(qw/http http_v2 proxy/)->plan(43); 26 my $t = Test::Nginx->new()->has(qw/http http_v2 proxy/)->plan(44);
27 27
28 $t->write_file_expand('nginx.conf', <<'EOF'); 28 $t->write_file_expand('nginx.conf', <<'EOF');
29 29
30 %%TEST_GLOBALS%% 30 %%TEST_GLOBALS%%
31 31
43 server_name localhost; 43 server_name localhost;
44 44
45 location / { 45 location / {
46 add_header X-Length $http_content_length; 46 add_header X-Length $http_content_length;
47 } 47 }
48 location /slow {
49 limit_rate 100;
50 }
48 location /off/ { 51 location /off/ {
49 proxy_pass http://127.0.0.1:8081/; 52 proxy_pass http://127.0.0.1:8081/;
53 add_header X-Body $request_body;
50 add_header X-Body-File $request_body_file; 54 add_header X-Body-File $request_body_file;
51 } 55 }
52 location /proxy2/ { 56 location /proxy2/ {
53 add_header X-Body $request_body; 57 add_header X-Body $request_body;
54 add_header X-Body-File $request_body_file; 58 add_header X-Body-File $request_body_file;
68 72
69 EOF 73 EOF
70 74
71 $t->write_file('index.html', ''); 75 $t->write_file('index.html', '');
72 $t->write_file('t.html', 'SEE-THIS'); 76 $t->write_file('t.html', 'SEE-THIS');
77 $t->write_file('slow.html', 'SEE-THIS');
73 $t->run(); 78 $t->run();
74 79
75 ############################################################################### 80 ###############################################################################
76 81
77 # request body (uses proxied response) 82 # request body (uses proxied response)
433 $sid = $s->new_stream({ path => '/off/t.html' }); 438 $sid = $s->new_stream({ path => '/off/t.html' });
434 $frames = $s->read(all => [{ sid => $sid, fin => 1 }]); 439 $frames = $s->read(all => [{ sid => $sid, fin => 1 }]);
435 440
436 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; 441 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
437 is($frame->{headers}->{'x-body-file'}, undef, 'no request body in file'); 442 is($frame->{headers}->{'x-body-file'}, undef, 'no request body in file');
443
444 # ticket #1384, request body corruption in recv_buffer
445
446 TODO: {
447 local $TODO = 'not yet' unless $t->has_version('1.13.6');
448
449 $s = Test::Nginx::HTTP2->new();
450 $sid = $s->new_stream({ path => '/off/slow.html', body_more => 1 });
451 select undef, undef, undef, 0.1;
452
453 # for simplicity, DATA frame is received on its own for a known offset
454
455 $s->h2_body('TEST');
456 select undef, undef, undef, 0.1;
457
458 # overwrite recv_buffer; since upstream response arrival is delayed,
459 # this would make $request_body point to the overridden buffer space
460
461 $s->h2_ping('xxxx');
462
463 $frames = $s->read(all => [{ sid => $sid, fin => 1 }]);
464 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
465 isnt($frame->{headers}->{'x-body'}, 'xxxx', 'sync buffer');
466
467 }
438 468
439 ############################################################################### 469 ###############################################################################
440 470
441 sub read_body_file { 471 sub read_body_file {
442 my ($path) = @_; 472 my ($path) = @_;