Mercurial > hg > nginx-tests
annotate image_filter.t @ 1260:eadd24ccfda1
Tests: postponed startup in certain ssl certificate tests on win32.
At least, some win32 hosts exhibit a round-off error or some such in the
notBefore field of the certificate generated before starting nginx, such
that it can be set to the value one second ahead of the current time.
This manifests in spurious test failures due to certificate verify error
with a failure reason "certificate is not yet valid".
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Tue, 12 Dec 2017 12:53:53 +0300 |
parents | 882267679006 |
children | 104701299b91 |
rev | line source |
---|---|
398
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
1 #!/usr/bin/perl |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
2 |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
3 # (C) Sergey Kandaurov |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
4 # (C) Nginx, Inc. |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
5 |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
6 # Tests for image filter module. |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
7 |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
8 ############################################################################### |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
9 |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
10 use warnings; |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
11 use strict; |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
12 |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
13 use Test::More; |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
14 |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
15 use Socket qw/CRLF/; |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
16 |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
17 BEGIN { use FindBin; chdir($FindBin::Bin); } |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
18 |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
19 use lib 'lib'; |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
20 use Test::Nginx; |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
21 |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
22 ############################################################################### |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
23 |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
24 select STDERR; $| = 1; |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
25 select STDOUT; $| = 1; |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
26 |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
27 eval { require GD; }; |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
28 plan(skip_all => 'GD not installed') if $@; |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
29 |
410
9fe6fc05c1d1
Tests: require "image_filter", not just "image".
Ruslan Ermilov <ru@nginx.com>
parents:
407
diff
changeset
|
30 my $t = Test::Nginx->new()->has(qw/http proxy map image_filter/)->plan(39) |
398
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
31 ->write_file_expand('nginx.conf', <<'EOF'); |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
32 |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
33 %%TEST_GLOBALS%% |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
34 |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
35 daemon off; |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
36 |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
37 events { |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
38 } |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
39 |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
40 http { |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
41 %%TEST_GLOBALS_HTTP%% |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
42 |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
43 map $arg_w $w { |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
44 "" '-'; |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
45 default $arg_w; |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
46 } |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
47 map $arg_h $h { |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
48 "" '-'; |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
49 default $arg_h; |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
50 } |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
51 |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
52 server { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
971
diff
changeset
|
53 listen 127.0.0.1:8080; |
398
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
54 server_name localhost; |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
55 |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
56 location /size { |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
57 image_filter size; |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
58 alias %%TESTDIR%%/; |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
59 } |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
60 |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
61 location /test { |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
62 image_filter test; |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
63 alias %%TESTDIR%%/; |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
64 |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
65 location /test/off { |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
66 image_filter off; |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
67 alias %%TESTDIR%%/; |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
68 } |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
69 } |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
70 |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
71 location /resize { |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
72 image_filter resize 10 12; |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
73 alias %%TESTDIR%%/; |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
74 } |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
75 location /resize1 { |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
76 image_filter resize 10 -; |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
77 alias %%TESTDIR%%/; |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
78 } |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
79 location /resize2 { |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
80 image_filter resize - 12; |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
81 alias %%TESTDIR%%/; |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
82 } |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
83 location /resize_var { |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
84 image_filter resize $w $h; |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
85 alias %%TESTDIR%%/; |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
86 } |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
87 |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
88 location /rotate { |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
89 image_filter rotate 90; |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
90 alias %%TESTDIR%%/; |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
91 } |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
92 location /rotate_var { |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
93 image_filter rotate $arg_r; |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
94 alias %%TESTDIR%%/; |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
95 } |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
96 |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
97 location /crop { |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
98 image_filter crop 60 80; |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
99 alias %%TESTDIR%%/; |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
100 } |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
101 location /crop_var { |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
102 image_filter crop $arg_w $arg_h; |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
103 alias %%TESTDIR%%/; |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
104 } |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
105 location /crop_rotate { |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
106 image_filter crop $arg_w $arg_h; |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
107 image_filter rotate $arg_r; |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
108 alias %%TESTDIR%%/; |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
109 } |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
110 location /resize_rotate { |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
111 image_filter resize $w $h; |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
112 image_filter rotate $arg_r; |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
113 alias %%TESTDIR%%/; |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
114 |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
115 location /resize_rotate/resize { |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
116 image_filter resize 10 12; |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
117 alias %%TESTDIR%%/; |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
118 } |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
119 } |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
120 |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
121 location /interlaced { |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
122 image_filter resize 10 12; |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
123 image_filter_interlace on; |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
124 alias %%TESTDIR%%/; |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
125 } |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
126 |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
127 location /nontransparent { |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
128 image_filter resize 10 12; |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
129 image_filter_transparency off; |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
130 alias %%TESTDIR%%/; |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
131 } |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
132 |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
133 location /quality { |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
134 image_filter resize 10 12; |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
135 image_filter_jpeg_quality 50; |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
136 alias %%TESTDIR%%/; |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
137 } |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
138 location /quality_var { |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
139 image_filter resize 10 12; |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
140 image_filter_jpeg_quality $arg_q; |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
141 alias %%TESTDIR%%/; |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
142 |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
143 location /quality_var/quality { |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
144 image_filter_jpeg_quality 60; |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
145 alias %%TESTDIR%%/; |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
146 } |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
147 } |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
148 |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
149 location /buffer { |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
150 image_filter test; |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
151 image_filter_buffer 1k; |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
152 alias %%TESTDIR%%/; |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
153 } |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
154 location /proxy_buffer { |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
155 image_filter rotate 90; |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
156 image_filter_buffer 20; |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
971
diff
changeset
|
157 proxy_pass http://127.0.0.1:8081/; |
398
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
158 proxy_buffering off; |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
159 proxy_buffer_size 512; |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
160 } |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
161 } |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
162 } |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
163 |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
164 EOF |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
165 |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
166 |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
167 my $im = new GD::Image(100, 120); |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
168 my $white = $im->colorAllocate(255, 255, 255); |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
169 my $black = $im->colorAllocate(0, 0, 0); |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
170 |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
171 $im->transparent($white); |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
172 $im->rectangle(0, 0, 99, 99, $black); |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
173 |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
174 $t->write_file('jpeg', $im->jpeg); |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
175 $t->write_file('gif', $im->gif); |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
176 $t->write_file('png', $im->png); |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
177 $t->write_file('txt', 'SEE-THIS'); |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
178 |
908
adf5671391ac
Tests: use read_file subroutine in several tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
611
diff
changeset
|
179 $t->run_daemon(\&http_daemon, $t); |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
971
diff
changeset
|
180 $t->run()->waitforsocket('127.0.0.1:' . port(8081)); |
398
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
181 |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
182 ############################################################################### |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
183 |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
184 like(http_head('/test/gif'), qr/200 OK/, 'test'); |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
185 like(http_head('/test/gif'), qr!Content-Type: image/gif!, 'test content-type'); |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
186 like(http_get('/test/txt'), qr/415 Unsupported/, 'test fail'); |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
187 like(http_get('/test/off/txt'), qr/SEE-THIS/, 'off'); |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
188 |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
189 is(http_get_body('/size/txt'), '{}' . CRLF, 'size wrong type'); |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
190 like(http_head('/size/txt'), qr!Content-Type: application/json!, |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
191 'size content-type'); |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
192 like(http_get('/size/jpeg'), qr/"width": 100/, 'size width'); |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
193 like(http_get('/size/jpeg'), qr/"height": 120/, 'size height'); |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
194 like(http_get('/size/jpeg'), qr/"type": "jpeg"/, 'size jpeg'); |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
195 like(http_get('/size/gif'), qr/"type": "gif"/, 'size gif'); |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
196 like(http_get('/size/png'), qr/"type": "png"/, 'size png'); |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
197 |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
198 is(gif_size('/resize/gif'), '10 12', 'resize'); |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
199 is(gif_size('/resize1/gif'), '10 12', 'resize 1'); |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
200 is(gif_size('/resize2/gif'), '10 12', 'resize 2'); |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
201 |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
202 is(gif_size('/resize_var/gif?w=10&h=12'), '10 12', 'resize var'); |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
203 is(gif_size('/resize_var/gif?w=10'), '10 12', 'resize var 1'); |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
204 is(gif_size('/resize_var/gif?h=12'), '10 12', 'resize var 2'); |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
205 |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
206 is(gif_size('/rotate/gif?r=90'), '120 100', 'rotate'); |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
207 is(gif_size('/rotate_var/gif?r=180'), '100 120', 'rotate var 1'); |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
208 is(gif_size('/rotate_var/gif?r=270'), '120 100', 'rotate var 2'); |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
209 |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
210 $im = GD::Image->newFromGifData(http_get_body('/gif')); |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
211 is($im->interlaced, 0, 'gif interlaced off'); |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
212 is($im->transparent, 0, 'gif transparent white'); |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
213 |
407
2711722a85c3
Tests: added safety measure for old libgd versions.
Sergey Kandaurov <pluknet@nginx.com>
parents:
398
diff
changeset
|
214 SKIP: { |
2711722a85c3
Tests: added safety measure for old libgd versions.
Sergey Kandaurov <pluknet@nginx.com>
parents:
398
diff
changeset
|
215 skip 'broken libgd', 1 unless has_gdversion('2.1.0') or $ENV{TEST_NGINX_UNSAFE}; |
2711722a85c3
Tests: added safety measure for old libgd versions.
Sergey Kandaurov <pluknet@nginx.com>
parents:
398
diff
changeset
|
216 |
398
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
217 $im = GD::Image->newFromGifData(http_get_body('/interlaced/gif')); |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
218 is($im->interlaced, 1, 'gif interlaced on'); |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
219 |
407
2711722a85c3
Tests: added safety measure for old libgd versions.
Sergey Kandaurov <pluknet@nginx.com>
parents:
398
diff
changeset
|
220 } |
2711722a85c3
Tests: added safety measure for old libgd versions.
Sergey Kandaurov <pluknet@nginx.com>
parents:
398
diff
changeset
|
221 |
398
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
222 $im = GD::Image->newFromGifData(http_get_body('/nontransparent/gif')); |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
223 is($im->transparent, -1, 'gif transparent loss'); |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
224 |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
225 $im = GD::Image->newFromPngData(http_get_body('/png')); |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
226 is($im->interlaced, 0, 'png interlaced off'); |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
227 is($im->transparent, 0, 'png transparent white'); |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
228 |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
229 # this test produces libpng warning on STDERR: |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
230 # "Interlace handling should be turned on when using png_read_image" |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
231 |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
232 SKIP: { |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
233 skip 'can wedge nginx with SIGPIPE', 1 unless $ENV{TEST_NGINX_UNSAFE}; |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
234 |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
235 $im = GD::Image->newFromPngData(http_get_body('/interlaced/png')); |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
236 is($im->interlaced, 1, 'png interlaced on'); |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
237 |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
238 } |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
239 |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
240 $im = GD::Image->newFromPngData(http_get_body('/nontransparent/png')); |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
241 is($im->transparent, -1, 'png transparent loss'); |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
242 |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
243 like(http_get('/resize/jpeg'), qr/quality = 75/, 'quality default'); |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
244 like(http_get('/quality/jpeg'), qr/quality = 50/, 'quality'); |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
245 like(http_get('/quality_var/jpeg?q=40'), qr/quality = 40/, 'quality var'); |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
246 like(http_get('/quality_var/quality/jpeg?q=40'), qr/quality = 60/, |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
247 'quality nested'); |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
248 |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
249 is(gif_size('/crop/gif'), '60 80', 'crop'); |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
250 is(gif_size('/crop_var/gif?w=10&h=20'), '10 20', 'crop var'); |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
251 is(gif_size('/crop_rotate/gif?w=5&h=6&r=90'), '5 5', 'rotate before crop'); |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
252 is(gif_size('/resize_rotate/gif?w=5&h=6&r=90'), '6 5', 'rotate after resize'); |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
253 is(gif_size('/resize_rotate/resize/gif??w=5&h=6&r=90'), '10 12', |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
254 'resize rotate nested'); |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
255 |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
256 like(http_get('/buffer/jpeg'), qr/415 Unsupported/, 'small buffer'); |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
257 isnt(http_get('/proxy_buffer/jpeg'), undef, 'small buffer proxy'); |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
258 |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
259 ############################################################################### |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
260 |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
261 sub gif_size { |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
262 join ' ', unpack("x6S2", http_get_body(@_)); |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
263 } |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
264 |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
265 sub http_get_body { |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
266 my ($uri) = @_; |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
267 |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
268 return undef if !defined $uri; |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
269 |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
270 my $text = http_get($uri); |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
271 |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
272 if ($text !~ /(.*?)\x0d\x0a?\x0d\x0a?(.*)/ms) { |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
273 return undef; |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
274 } |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
275 |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
276 return $2; |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
277 } |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
278 |
407
2711722a85c3
Tests: added safety measure for old libgd versions.
Sergey Kandaurov <pluknet@nginx.com>
parents:
398
diff
changeset
|
279 sub has_gdversion { |
2711722a85c3
Tests: added safety measure for old libgd versions.
Sergey Kandaurov <pluknet@nginx.com>
parents:
398
diff
changeset
|
280 my ($need) = @_; |
2711722a85c3
Tests: added safety measure for old libgd versions.
Sergey Kandaurov <pluknet@nginx.com>
parents:
398
diff
changeset
|
281 |
971
ed99be008b52
Tests: adjusted libgd version check for recent versions.
Sergey Kandaurov <pluknet@nginx.com>
parents:
952
diff
changeset
|
282 my $v_str = `gdlib-config --version 2>&1` or return 1; |
ed99be008b52
Tests: adjusted libgd version check for recent versions.
Sergey Kandaurov <pluknet@nginx.com>
parents:
952
diff
changeset
|
283 ($v_str) = $v_str =~ m!^([0-9.]+)! or return 1; |
407
2711722a85c3
Tests: added safety measure for old libgd versions.
Sergey Kandaurov <pluknet@nginx.com>
parents:
398
diff
changeset
|
284 my @v = split(/\./, $v_str); |
2711722a85c3
Tests: added safety measure for old libgd versions.
Sergey Kandaurov <pluknet@nginx.com>
parents:
398
diff
changeset
|
285 my ($n, $v); |
2711722a85c3
Tests: added safety measure for old libgd versions.
Sergey Kandaurov <pluknet@nginx.com>
parents:
398
diff
changeset
|
286 |
2711722a85c3
Tests: added safety measure for old libgd versions.
Sergey Kandaurov <pluknet@nginx.com>
parents:
398
diff
changeset
|
287 for $n (split(/\./, $need)) { |
2711722a85c3
Tests: added safety measure for old libgd versions.
Sergey Kandaurov <pluknet@nginx.com>
parents:
398
diff
changeset
|
288 $v = shift @v || 0; |
2711722a85c3
Tests: added safety measure for old libgd versions.
Sergey Kandaurov <pluknet@nginx.com>
parents:
398
diff
changeset
|
289 return 0 if $n > $v; |
2711722a85c3
Tests: added safety measure for old libgd versions.
Sergey Kandaurov <pluknet@nginx.com>
parents:
398
diff
changeset
|
290 return 1 if $v > $n; |
2711722a85c3
Tests: added safety measure for old libgd versions.
Sergey Kandaurov <pluknet@nginx.com>
parents:
398
diff
changeset
|
291 } |
2711722a85c3
Tests: added safety measure for old libgd versions.
Sergey Kandaurov <pluknet@nginx.com>
parents:
398
diff
changeset
|
292 |
2711722a85c3
Tests: added safety measure for old libgd versions.
Sergey Kandaurov <pluknet@nginx.com>
parents:
398
diff
changeset
|
293 return 1; |
2711722a85c3
Tests: added safety measure for old libgd versions.
Sergey Kandaurov <pluknet@nginx.com>
parents:
398
diff
changeset
|
294 } |
2711722a85c3
Tests: added safety measure for old libgd versions.
Sergey Kandaurov <pluknet@nginx.com>
parents:
398
diff
changeset
|
295 |
398
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
296 ############################################################################### |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
297 |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
298 # serve static files without Content-Length |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
299 |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
300 sub http_daemon { |
908
adf5671391ac
Tests: use read_file subroutine in several tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
611
diff
changeset
|
301 my ($t) = @_; |
398
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
302 |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
303 my $server = IO::Socket::INET->new( |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
304 Proto => 'tcp', |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
305 LocalHost => '127.0.0.1', |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
971
diff
changeset
|
306 LocalPort => port(8081), |
398
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
307 Listen => 5, |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
308 Reuse => 1 |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
309 ) |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
310 or die "Can't create listening socket: $!\n"; |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
311 |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
312 local $SIG{PIPE} = 'IGNORE'; |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
313 |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
314 while (my $client = $server->accept()) { |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
315 $client->autoflush(1); |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
316 |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
317 my $headers = ''; |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
318 my $uri = ''; |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
319 |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
320 while (<$client>) { |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
321 $headers .= $_; |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
322 last if (/^\x0d?\x0a?$/); |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
323 } |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
324 |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
325 next if $headers eq ''; |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
326 $uri = $1 if $headers =~ /^\S+\s+([^ ]+)\s+HTTP/i; |
908
adf5671391ac
Tests: use read_file subroutine in several tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
611
diff
changeset
|
327 my $data = $t->read_file($uri); |
398
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
328 |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
329 print $client <<EOF; |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
330 HTTP/1.1 200 OK |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
331 Connection: close |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
332 |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
333 $data |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
334 EOF |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
335 |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
336 } continue { |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
337 close $client; |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
338 } |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
339 } |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
340 |
077ffeac825c
Tests: image filter tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
341 ############################################################################### |