Mercurial > hg > nginx-tests
comparison h2_limit_req.t @ 1720:efc502e696b0
Tests: h2_limit_req.t cleanup.
The checks were used prior to introducing the request body preread buffer.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Tue, 20 Jul 2021 16:12:53 +0300 |
parents | 196d33c2bb45 |
children | 9a44d489966c |
comparison
equal
deleted
inserted
replaced
1719:53a801bf4d0b | 1720:efc502e696b0 |
---|---|
102 is($frame->{headers}->{':status'}, 200, 'request body - limit req - empty'); | 102 is($frame->{headers}->{':status'}, 200, 'request body - limit req - empty'); |
103 | 103 |
104 # predict send windows | 104 # predict send windows |
105 | 105 |
106 $sid = $s->new_stream(); | 106 $sid = $s->new_stream(); |
107 my ($maxwin) = sort {$a <=> $b} $s->{streams}{$sid}, $s->{conn_window}; | |
108 | |
109 SKIP: { | |
110 skip 'not enough window', 1 if $maxwin < 5; | |
111 | |
112 $s = Test::Nginx::HTTP2->new(); | 107 $s = Test::Nginx::HTTP2->new(); |
113 $sid = $s->new_stream({ path => '/proxy_limit_req/', body => 'TEST2' }); | 108 $sid = $s->new_stream({ path => '/proxy_limit_req/', body => 'TEST2' }); |
114 select undef, undef, undef, 1.1; | 109 select undef, undef, undef, 1.1; |
115 $frames = $s->read(all => [{ sid => $sid, fin => 1 }]); | 110 $frames = $s->read(all => [{ sid => $sid, fin => 1 }]); |
116 | 111 |
117 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | 112 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; |
118 is(read_body_file($frame->{headers}->{'x-body-file'}), 'TEST2', | 113 is(read_body_file($frame->{headers}->{'x-body-file'}), 'TEST2', |
119 'request body - limit req 2'); | 114 'request body - limit req 2'); |
120 | 115 |
121 } | |
122 | |
123 # partial request body data frame received (to be discarded) within request | 116 # partial request body data frame received (to be discarded) within request |
124 # delayed in limit_req, the rest of data frame is received after response | 117 # delayed in limit_req, the rest of data frame is received after response |
125 | 118 |
126 $s = Test::Nginx::HTTP2->new(); | 119 $s = Test::Nginx::HTTP2->new(); |
127 | |
128 SKIP: { | |
129 skip 'not enough window', 1 if $maxwin < 4; | |
130 | |
131 $sid = $s->new_stream({ path => '/limit_req', body => 'TEST', split => [61], | 120 $sid = $s->new_stream({ path => '/limit_req', body => 'TEST', split => [61], |
132 split_delay => 1.1 }); | 121 split_delay => 1.1 }); |
133 $frames = $s->read(all => [{ sid => $sid, fin => 1 }]); | 122 $frames = $s->read(all => [{ sid => $sid, fin => 1 }]); |
134 | 123 |
135 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | 124 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; |
136 is($frame->{headers}->{':status'}, '200', 'discard body - limit req - limited'); | 125 is($frame->{headers}->{':status'}, '200', 'discard body - limit req - limited'); |
137 | |
138 } | |
139 | 126 |
140 $sid = $s->new_stream({ path => '/' }); | 127 $sid = $s->new_stream({ path => '/' }); |
141 $frames = $s->read(all => [{ sid => $sid, fin => 1 }]); | 128 $frames = $s->read(all => [{ sid => $sid, fin => 1 }]); |
142 | 129 |
143 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; | 130 ($frame) = grep { $_->{type} eq "HEADERS" } @$frames; |
144 is($frame->{headers}->{':status'}, '200', 'discard body - limit req - next'); | 131 is($frame->{headers}->{':status'}, '200', 'discard body - limit req - next'); |
145 | 132 |
146 # ditto, but instead of receiving the rest of data frame, connection is closed | 133 # ditto, but instead of receiving the rest of data frame, connection is closed |
147 # 'http request already closed while closing request' alert can be produced | 134 # 'http request already closed while closing request' alert can be produced |
148 | 135 |
149 SKIP: { | |
150 skip 'not enough window', 1 if $maxwin < 4; | |
151 | |
152 $s = Test::Nginx::HTTP2->new(); | 136 $s = Test::Nginx::HTTP2->new(); |
153 $sid = $s->new_stream({ path => '/limit_req', body => 'TEST', split => [61], | 137 $sid = $s->new_stream({ path => '/limit_req', body => 'TEST', split => [61], |
154 abort => 1 }); | 138 abort => 1 }); |
155 | 139 |
156 select undef, undef, undef, 1.1; | 140 select undef, undef, undef, 1.1; |
157 close $s->{socket}; | 141 close $s->{socket}; |
158 | 142 |
159 pass('discard body - limit req - eof'); | 143 pass('discard body - limit req - eof'); |
160 | |
161 } | |
162 | 144 |
163 ############################################################################### | 145 ############################################################################### |
164 | 146 |
165 sub read_body_file { | 147 sub read_body_file { |
166 my ($path) = @_; | 148 my ($path) = @_; |