comparison h2_proxy_request_buffering_redirect.t @ 1498:63a74974a0e9

Tests: HTTP/2 unbuffered request body with redirect (ticket #1819).
author Sergey Kandaurov <pluknet@nginx.com>
date Mon, 19 Aug 2019 17:17:42 +0300
parents
children 03f8fb9f6492
comparison
equal deleted inserted replaced
1497:40e5f2a0a238 1498:63a74974a0e9
1 #!/usr/bin/perl
2
3 # (C) Sergey Kandaurov
4 # (C) Nginx, Inc.
5
6 # Tests for HTTP/2 protocol with unbuffered request body.
7
8 ###############################################################################
9
10 use warnings;
11 use strict;
12
13 use Test::More;
14
15 BEGIN { use FindBin; chdir($FindBin::Bin); }
16
17 use lib 'lib';
18 use Test::Nginx;
19 use Test::Nginx::HTTP2;
20
21 ###############################################################################
22
23 select STDERR; $| = 1;
24 select STDOUT; $| = 1;
25
26 my $t = Test::Nginx->new()->has(qw/http http_v2 proxy rewrite/)->plan(1);
27
28 $t->write_file_expand('nginx.conf', <<'EOF')->run();
29
30 %%TEST_GLOBALS%%
31
32 daemon off;
33
34 events {
35 }
36
37 http {
38 %%TEST_GLOBALS_HTTP%%
39
40 server {
41 listen 127.0.0.1:8080 http2;
42 listen 127.0.0.1:8081;
43 server_name localhost;
44
45 proxy_http_version 1.1;
46
47 location / {
48 proxy_request_buffering off;
49 proxy_pass http://127.0.0.1:8081/bad;
50 proxy_intercept_errors on;
51 error_page 502 = /pass;
52 }
53
54 location /bad {
55 return 502;
56 }
57
58 location /pass {
59 proxy_pass http://127.0.0.1:8081/good;
60 }
61
62 location /good {
63 limit_rate 100;
64 return 200;
65 }
66 }
67 }
68
69 EOF
70
71 ###############################################################################
72
73 # unbuffered request body
74
75 TODO: {
76 todo_skip 'leaves coredump', 1 unless $ENV{TEST_NGINX_UNSAFE}
77 or $t->has_version('1.17.4');
78
79 my $s = Test::Nginx::HTTP2->new();
80 my $sid = $s->new_stream({ body_more => 1 });
81
82 $s->h2_body('SEE-', { body_more => 1 });
83 sleep 1;
84 $s->h2_body('THIS');
85
86 my $frames = $s->read(all => [{ sid => $sid, fin => 1 }]);
87 my ($frame) = grep { $_->{type} eq "HEADERS" } @$frames;
88 is($frame->{headers}->{':status'}, 200, 'discard body rest on redirect');
89
90 }
91
92 ###############################################################################