Mercurial > hg > nginx-tests
comparison proxy_ssi_body.t @ 422:ddc4b1011333
Tests: test for proxied subrequest with request body in file.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Tue, 01 Jul 2014 20:36:57 +0400 |
parents | |
children | 8dd5cf697eae |
comparison
equal
deleted
inserted
replaced
421:e8db4355fe0b | 422:ddc4b1011333 |
---|---|
1 #!/usr/bin/perl | |
2 | |
3 # (C) Sergey Kandaurov | |
4 # (C) Nginx, Inc. | |
5 | |
6 # Test for proxied subrequest with request body in file. | |
7 | |
8 ############################################################################### | |
9 | |
10 use warnings; | |
11 use strict; | |
12 | |
13 use Test::More; | |
14 | |
15 use Socket qw/ CRLF /; | |
16 | |
17 BEGIN { use FindBin; chdir($FindBin::Bin); } | |
18 | |
19 use lib 'lib'; | |
20 use Test::Nginx; | |
21 | |
22 ############################################################################### | |
23 | |
24 select STDERR; $| = 1; | |
25 select STDOUT; $| = 1; | |
26 | |
27 my $t = Test::Nginx->new()->has(qw/http proxy ssi/)->plan(1); | |
28 | |
29 $t->write_file_expand('nginx.conf', <<'EOF'); | |
30 | |
31 %%TEST_GLOBALS%% | |
32 | |
33 daemon off; | |
34 | |
35 events { | |
36 } | |
37 | |
38 http { | |
39 %%TEST_GLOBALS_HTTP%% | |
40 | |
41 server { | |
42 listen 127.0.0.1:8080; | |
43 server_name localhost; | |
44 | |
45 location / { | |
46 } | |
47 | |
48 location /proxy { | |
49 proxy_pass http://127.0.0.1:8080/; | |
50 client_body_in_file_only on; | |
51 ssi on; | |
52 } | |
53 } | |
54 } | |
55 | |
56 EOF | |
57 | |
58 $t->write_file('ssi.html', 'X<!--# include virtual="test.html" -->X'); | |
59 $t->write_file('test.html', 'YY'); | |
60 | |
61 $t->run(); | |
62 | |
63 ############################################################################### | |
64 | |
65 # Request body cache file is released once a response is got. | |
66 # If later a subrequest tries to use body, it fails. | |
67 | |
68 TODO: { | |
69 local $TODO = 'prematurely pruned'; | |
70 | |
71 like(http_get_body('/proxy/ssi.html', "1234567890"), qr/^XYYX$/m, | |
72 'body in file in proxied subrequest'); | |
73 | |
74 } | |
75 | |
76 ############################################################################### | |
77 | |
78 sub http_get_body { | |
79 my ($url, $body, %extra) = @_; | |
80 | |
81 my $p = "GET $url HTTP/1.0" . CRLF | |
82 . "Host: localhost" . CRLF | |
83 . "Content-Length: " . (length $body) . CRLF . CRLF | |
84 . $body; | |
85 | |
86 return http($p, %extra); | |
87 } | |
88 | |
89 ############################################################################### |