Mercurial > hg > nginx-tests
annotate empty_gif.t @ 1983:c7315caf2110
Tests: optimized processing of large QUIC packets with padding.
Path MTU discovery packets might contain a lot of padding, and creating
a copy of the whole buffer for each PADDING frame, which is just one
byte with type 0, consumes lots of resources. This was seen to result
in flapping of at least h3_keepalive.t and h3_ssl_early_data.t tests.
Fix is to copy at most 8 bytes for parse_int() calls when parsing
frame types.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Mon, 03 Jun 2024 04:17:28 +0300 |
parents | c544b7120a6d |
children |
rev | line source |
---|---|
326 | 1 #!/usr/bin/perl |
2 | |
3 # (C) Sergey Kandaurov | |
4 | |
5 # Tests for empty gif module. | |
6 | |
7 ############################################################################### | |
8 | |
9 use warnings; | |
10 use strict; | |
11 | |
12 use Test::More; | |
13 | |
14 use Socket qw/ CRLF /; | |
15 | |
16 BEGIN { use FindBin; chdir($FindBin::Bin); } | |
17 | |
18 use lib 'lib'; | |
19 use Test::Nginx; | |
20 | |
21 ############################################################################### | |
22 | |
23 select STDERR; $| = 1; | |
24 select STDOUT; $| = 1; | |
25 | |
26 my $t = Test::Nginx->new()->has(qw/http empty_gif/)->plan(4); | |
27 | |
28 $t->write_file_expand('nginx.conf', <<'EOF'); | |
29 | |
30 %%TEST_GLOBALS%% | |
31 | |
32 daemon off; | |
33 | |
34 events { | |
35 } | |
36 | |
37 http { | |
38 %%TEST_GLOBALS_HTTP%% | |
39 | |
40 server { | |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
41 listen 127.0.0.1:8080; |
326 | 42 server_name localhost; |
43 | |
44 location / { | |
45 empty_gif; | |
46 } | |
47 } | |
48 } | |
49 | |
50 EOF | |
51 | |
52 $t->run(); | |
53 | |
54 my $gif = unhex(<<'EOF'); | |
55 0x0000: 47 49 46 38 39 61 01 00 01 00 80 01 00 00 00 00 |GIF89a.. ........| | |
56 0x0010: ff ff ff 21 f9 04 01 00 00 01 00 2c 00 00 00 00 |...!.... ...,....| | |
57 0x0020: 01 00 01 00 00 02 02 4c 01 00 3b |.......L ..;| | |
58 EOF | |
59 | |
60 ############################################################################### | |
61 | |
62 is(http_get_body('/'), $gif, 'empty gif'); | |
63 like(http_get('/'), qr!Content-Type: image/gif!i, 'get content type'); | |
64 like(http_head('/'), qr!Content-Type: image/gif!i, 'head content type'); | |
1957
c544b7120a6d
Tests: removed dependencies on 405 error text.
Maxim Dounin <mdounin@mdounin.ru>
parents:
974
diff
changeset
|
65 like(http('PUT / HTTP/1.0' . CRLF . CRLF), qr! 405 !i, 'put'); |
326 | 66 |
67 ############################################################################### | |
68 | |
69 sub unhex { | |
70 my ($input) = @_; | |
71 my $buffer = ''; | |
72 | |
73 for my $l ($input =~ m/: +((?:[0-9a-f]{2,4} +)+) /gms) { | |
74 for my $v ($l =~ m/[0-9a-f]{2}/g) { | |
75 $buffer .= chr(hex($v)); | |
76 } | |
77 } | |
78 | |
79 return $buffer; | |
80 } | |
81 | |
82 sub http_get_body { | |
83 my ($uri) = @_; | |
84 | |
85 return undef if !defined $uri; | |
86 | |
87 my $text = http_get($uri); | |
88 | |
89 if ($text !~ /(.*?)\x0d\x0a?\x0d\x0a?(.*)/ms) { | |
90 return undef; | |
91 } | |
92 | |
93 return $2; | |
94 } | |
95 | |
96 ############################################################################### |