Mercurial > hg > nginx-tests
comparison h2_proxy_protocol.t @ 946:e3df9c2100de
Tests: fixed HTTP/2 test with invalid PROXY protocol string.
Previously it tested invalid connection preface.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Wed, 15 Jun 2016 19:00:45 +0300 |
parents | e309d9701007 |
children | 4dc302d8e04f |
comparison
equal
deleted
inserted
replaced
945:d73bef563aea | 946:e3df9c2100de |
---|---|
37 | 37 |
38 http { | 38 http { |
39 %%TEST_GLOBALS_HTTP%% | 39 %%TEST_GLOBALS_HTTP%% |
40 | 40 |
41 server { | 41 server { |
42 listen 127.0.0.1:8080 http2; | |
43 listen 127.0.0.1:8081 proxy_protocol http2; | 42 listen 127.0.0.1:8081 proxy_protocol http2; |
44 server_name localhost; | 43 server_name localhost; |
45 | 44 |
46 location /pp { | 45 location /pp { |
47 set_real_ip_from 127.0.0.1/32; | 46 set_real_ip_from 127.0.0.1/32; |
68 ok($frame, 'PROXY HEADERS frame'); | 67 ok($frame, 'PROXY HEADERS frame'); |
69 is($frame->{headers}->{'x-pp'}, '192.0.2.1', 'PROXY remote addr'); | 68 is($frame->{headers}->{'x-pp'}, '192.0.2.1', 'PROXY remote addr'); |
70 | 69 |
71 # invalid PROXY protocol string | 70 # invalid PROXY protocol string |
72 | 71 |
73 my $s = http('BOGUS TCP4 192.0.2.1 192.0.2.2 1234 5678', start => 1); | 72 $proxy = 'BOGUS TCP4 192.0.2.1 192.0.2.2 1234 5678' . CRLF; |
74 $frames = h2_read({ socket => $s }, all => [{ type => 'GOAWAY' }]); | 73 $sess = new_session(8081, preface => $proxy, pure => 1); |
74 $frames = h2_read($sess, all => [{ type => 'GOAWAY' }]); | |
75 | 75 |
76 ($frame) = grep { $_->{type} eq "GOAWAY" } @$frames; | 76 ($frame) = grep { $_->{type} eq "GOAWAY" } @$frames; |
77 ok($frame, 'invalid PROXY - GOAWAY frame'); | 77 ok($frame, 'invalid PROXY - GOAWAY frame'); |
78 is($frame->{code}, 1, 'invalid PROXY - error code'); | 78 is($frame->{code}, 1, 'invalid PROXY - error code'); |
79 | 79 |