comparison proxy_max_temp_file_size.t @ 1730:696322b7e2c3

Tests: added proxy_max_temp_file_size tests.
author Sergey Kandaurov <pluknet@nginx.com>
date Wed, 15 Sep 2021 16:37:32 +0300
parents
children
comparison
equal deleted inserted replaced
1729:14b5ee6eee6c 1730:696322b7e2c3
1 #!/usr/bin/perl
2
3 # (C) Sergey Kandaurov
4 # (C) Nginx, Inc.
5
6 # Tests for http proxy module, proxy_max_temp_file_size directive.
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 qw/ :DEFAULT http_content /;
19
20 ###############################################################################
21
22 select STDERR; $| = 1;
23 select STDOUT; $| = 1;
24
25 my $t = Test::Nginx->new()->has(qw/http proxy/)->plan(4);
26
27 $t->write_file_expand('nginx.conf', <<'EOF');
28
29 %%TEST_GLOBALS%%
30
31 daemon off;
32
33 events {
34 }
35
36 http {
37 %%TEST_GLOBALS_HTTP%%
38
39 server {
40 listen 127.0.0.1:8080 sndbuf=32k;
41 server_name localhost;
42
43 proxy_buffer_size 4k;
44 proxy_buffers 8 4k;
45
46 location / {
47 proxy_max_temp_file_size 4k;
48 proxy_pass http://127.0.0.1:8081/;
49 }
50
51 location /off/ {
52 proxy_max_temp_file_size 0;
53 proxy_pass http://127.0.0.1:8081/;
54 }
55 }
56
57 server {
58 listen 127.0.0.1:8081;
59 server_name localhost;
60
61 location / { }
62 }
63 }
64
65 EOF
66
67 $t->write_file('1', 'X' x (1024 * 1024));
68 $t->run();
69
70 ###############################################################################
71
72 # test that the response is wholly proxied when all event pipe buffers are full
73
74 my $body = http_content(http_get('/1', sleep => 0.4));
75 like($body, qr/^X+$/m, 'no pipe bufs - body');
76 is(length($body), 1024 * 1024, 'no pipe bufs - body length');
77
78 # also with disabled proxy temp file
79
80 $body = http_content(http_get('/off/1', sleep => 0.4));
81 like($body, qr/^X+$/m, 'no temp file - body');
82 is(length($body), 1024 * 1024, 'no temp file - body length');
83
84 ###############################################################################