Mercurial > hg > nginx-tests
comparison h2_priority.t @ 1506:c4c2275cda55
Tests: expect GOAWAY on HTTP/2 frames with dependency on itself.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Mon, 09 Sep 2019 17:16:00 +0300 |
parents | 882267679006 |
children | 48306d8a2811 |
comparison
equal
deleted
inserted
replaced
1505:76090a5da00b | 1506:c4c2275cda55 |
---|---|
204 # PRIORITY - self dependency | 204 # PRIORITY - self dependency |
205 | 205 |
206 # 5.3.1. Stream Dependencies | 206 # 5.3.1. Stream Dependencies |
207 # A stream cannot depend on itself. An endpoint MUST treat this as a | 207 # A stream cannot depend on itself. An endpoint MUST treat this as a |
208 # stream error of type PROTOCOL_ERROR. | 208 # stream error of type PROTOCOL_ERROR. |
209 # Instead, we respond with a connection error of type PROTOCOL_ERROR. | |
210 | |
211 TODO: { | |
212 local $TODO = 'not yet'; | |
209 | 213 |
210 $s = Test::Nginx::HTTP2->new(); | 214 $s = Test::Nginx::HTTP2->new(); |
211 $sid = $s->new_stream(); | 215 $sid = $s->new_stream(); |
212 $s->read(all => [{ sid => $sid, fin => 1 }]); | 216 $s->read(all => [{ sid => $sid, fin => 1 }]); |
213 | 217 |
214 $s->h2_priority(0, $sid, $sid); | 218 $s->h2_priority(0, $sid, $sid); |
215 $frames = $s->read(all => [{ type => 'RST_STREAM' }]); | 219 $frames = $s->read(all => [{ type => 'GOAWAY' }]); |
216 | 220 |
217 my ($frame) = grep { $_->{type} eq "RST_STREAM" } @$frames; | 221 my ($frame) = grep { $_->{type} eq "GOAWAY" } @$frames; |
218 is($frame->{sid}, $sid, 'dependency - PRIORITY self - RST_STREAM'); | 222 is($frame->{last_sid}, $sid, 'dependency - PRIORITY self - GOAWAY'); |
219 is($frame->{code}, 1, 'dependency - PRIORITY self - PROTOCOL_ERROR'); | 223 is($frame->{code}, 1, 'dependency - PRIORITY self - PROTOCOL_ERROR'); |
224 | |
225 } | |
220 | 226 |
221 # HEADERS PRIORITY flag, reprioritize prior PRIORITY frame records | 227 # HEADERS PRIORITY flag, reprioritize prior PRIORITY frame records |
222 | 228 |
223 $s = Test::Nginx::HTTP2->new(); | 229 $s = Test::Nginx::HTTP2->new(); |
224 | 230 |
270 $sids = join ' ', map { $_->{sid} } @data; | 276 $sids = join ' ', map { $_->{sid} } @data; |
271 is($sids, "$sid $sid2", 'dependency - HEADERS PRIORITY 2'); | 277 is($sids, "$sid $sid2", 'dependency - HEADERS PRIORITY 2'); |
272 | 278 |
273 # HEADERS - self dependency | 279 # HEADERS - self dependency |
274 | 280 |
281 TODO: { | |
282 local $TODO = 'not yet'; | |
283 | |
275 $s = Test::Nginx::HTTP2->new(); | 284 $s = Test::Nginx::HTTP2->new(); |
276 $sid = $s->new_stream({ dep => 1 }); | 285 $sid = $s->new_stream({ dep => 1 }); |
277 $frames = $s->read(all => [{ type => 'RST_STREAM' }]); | 286 $frames = $s->read(all => [{ type => 'GOAWAY' }]); |
278 | 287 |
279 ($frame) = grep { $_->{type} eq "RST_STREAM" } @$frames; | 288 my ($frame) = grep { $_->{type} eq "GOAWAY" } @$frames; |
280 is($frame->{sid}, $sid, 'dependency - HEADERS self - RST_STREAM'); | 289 is($frame->{last_sid}, 0, 'dependency - HEADERS self - GOAWAY'); |
281 is($frame->{code}, 1, 'dependency - HEADERS self - PROTOCOL_ERROR'); | 290 is($frame->{code}, 1, 'dependency - HEADERS self - PROTOCOL_ERROR'); |
291 | |
292 } | |
282 | 293 |
283 # PRIORITY frame, weighted dependencies | 294 # PRIORITY frame, weighted dependencies |
284 | 295 |
285 $s = Test::Nginx::HTTP2->new(); | 296 $s = Test::Nginx::HTTP2->new(); |
286 | 297 |
389 $frames = $s->read(all => [ | 400 $frames = $s->read(all => [ |
390 { sid => $sid, fin => 1 }, | 401 { sid => $sid, fin => 1 }, |
391 { sid => $sid3, fin => 1 }, | 402 { sid => $sid3, fin => 1 }, |
392 ]); | 403 ]); |
393 | 404 |
394 ($frame) = grep { $_->{type} eq "DATA" && $_->{sid} == $sid } @$frames; | 405 my ($frame) = grep { $_->{type} eq "DATA" && $_->{sid} == $sid } @$frames; |
395 is($frame->{length}, 81, 'removed dependency - first stream'); | 406 is($frame->{length}, 81, 'removed dependency - first stream'); |
396 | 407 |
397 ($frame) = grep { $_->{type} eq "DATA" && $_->{sid} == $sid3 } @$frames; | 408 ($frame) = grep { $_->{type} eq "DATA" && $_->{sid} == $sid3 } @$frames; |
398 is($frame->{length}, 81, 'removed dependency - last stream'); | 409 is($frame->{length}, 81, 'removed dependency - last stream'); |
399 | 410 |