xref: /lighttpd1.4/tests/request.t (revision 5ba17526)
1#!/usr/bin/env perl
2BEGIN {
3	# add current source dir to the include-path
4	# we need this for make distcheck
5	(my $srcdir = $0) =~ s,/[^/]+$,/,;
6	unshift @INC, $srcdir;
7}
8
9use strict;
10use IO::Socket;
11use Test::More tests => 51;
12use LightyTest;
13
14my $tf = LightyTest->new();
15my $t;
16
17ok($tf->start_proc == 0, "Starting lighttpd") or die();
18
19## Basic Request-Handling
20
21$t->{REQUEST}  = ( <<EOF
22GET /foobar HTTP/1.0
23EOF
24 );
25$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 404 } ];
26ok($tf->handle_http($t) == 0, 'file not found');
27
28$t->{REQUEST}  = ( <<EOF
29GET /foobar?foobar HTTP/1.0
30EOF
31 );
32$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 404 } ];
33ok($tf->handle_http($t) == 0, 'file not found + querystring');
34
35$t->{REQUEST}  = ( <<EOF
36GET /12345.txt HTTP/1.0
37Host: 123.example.org
38EOF
39 );
40$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => '12345'."\n", 'Content-Type' => 'text/plain' } ];
41ok($tf->handle_http($t) == 0, 'GET, content == 12345, mimetype text/plain');
42
43$t->{REQUEST}  = ( <<EOF
44GET /12345.html HTTP/1.0
45Host: 123.example.org
46EOF
47 );
48$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => '12345'."\n", 'Content-Type' => 'text/html' } ];
49ok($tf->handle_http($t) == 0, 'GET, content == 12345, mimetype text/html');
50
51$t->{REQUEST}  = ( <<EOF
52GET /dummyfile.bla HTTP/1.0
53Host: 123.example.org
54EOF
55 );
56$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => '12345'."\n", 'Content-Type' => 'application/octet-stream' } ];
57ok($tf->handle_http($t) == 0, 'GET, content == 12345, mimetype application/octet-stream');
58
59
60$t->{REQUEST}  = ( <<EOF
61POST / HTTP/1.0
62Content-type: application/x-www-form-urlencoded
63Content-length: 0
64EOF
65 );
66$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } ];
67ok($tf->handle_http($t) == 0, 'POST request, empty request-body');
68
69$t->{REQUEST}  = ( <<EOF
70HEAD / HTTP/1.0
71EOF
72 );
73$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, '-HTTP-Content' => ''} ];
74ok($tf->handle_http($t) == 0, 'HEAD request, no content');
75
76$t->{REQUEST}  = ( <<EOF
77HEAD /12345.html HTTP/1.0
78Host: 123.example.org
79EOF
80 );
81$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, '-HTTP-Content' => '', 'Content-Type' => 'text/html', 'Content-Length' => '6'} ];
82ok($tf->handle_http($t) == 0, 'HEAD request, mimetype text/html, content-length');
83
84$t->{REQUEST}  = ( <<EOF
85HEAD http://123.example.org/12345.html HTTP/1.1
86Connection: close
87EOF
88 );
89$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.1', 'HTTP-Status' => 200, '-HTTP-Content' => '', 'Content-Type' => 'text/html', 'Content-Length' => '6'} ];
90ok($tf->handle_http($t) == 0, 'Hostname in first line, HTTP/1.1');
91
92$t->{REQUEST}  = ( <<EOF
93HEAD https://123.example.org/12345.html HTTP/1.0
94EOF
95 );
96$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, '-HTTP-Content' => '', 'Content-Type' => 'text/html', 'Content-Length' => '6'} ];
97ok($tf->handle_http($t) == 0, 'Hostname in first line as https url');
98
99$t->{REQUEST}  = ( <<EOF
100HEAD /foobar?foobar HTTP/1.0
101EOF
102 );
103$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 404, '-HTTP-Content' => '' } ];
104ok($tf->handle_http($t) == 0, 'HEAD request, file-not-found, query-string');
105
106# (expect 200 OK instead of 100 Continue since request body sent with request)
107# (if we waited to send request body, would expect 100 Continue, first)
108$t->{REQUEST}  = ( <<EOF
109POST /get-post-len.pl HTTP/1.1
110Host: www.example.org
111Connection: close
112Content-Type: application/x-www-form-urlencoded
113Content-Length: 4
114Expect: 100-continue
115
116123
117EOF
118 );
119$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.1', 'HTTP-Status' => 200 } ];
120ok($tf->handle_http($t) == 0, 'Continue, Expect');
121
122# note Transfer-Encoding: chunked tests will fail with 411 Length Required if
123#   server.stream-request-body != 0 in lighttpd.conf
124$t->{REQUEST}  = ( <<EOF
125POST /get-post-len.pl HTTP/1.1
126Host: www.example.org
127Connection: close
128Content-Type: application/x-www-form-urlencoded
129Transfer-Encoding: chunked
130
131a
1320123456789
1330
134
135EOF
136 );
137$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.1', 'HTTP-Status' => 200 } ];
138ok($tf->handle_http($t) == 0, 'POST via Transfer-Encoding: chunked, lc hex');
139
140$t->{REQUEST}  = ( <<EOF
141POST /get-post-len.pl HTTP/1.1
142Host: www.example.org
143Connection: close
144Content-Type: application/x-www-form-urlencoded
145Transfer-Encoding: chunked
146
147A
1480123456789
1490
150
151EOF
152 );
153$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.1', 'HTTP-Status' => 200 } ];
154ok($tf->handle_http($t) == 0, 'POST via Transfer-Encoding: chunked, uc hex');
155
156$t->{REQUEST}  = ( <<EOF
157POST /get-post-len.pl HTTP/1.1
158Host: www.example.org
159Connection: close
160Content-Type: application/x-www-form-urlencoded
161Transfer-Encoding: chunked
162
16310
1640123456789abcdef
1650
166
167EOF
168 );
169$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.1', 'HTTP-Status' => 200 } ];
170ok($tf->handle_http($t) == 0, 'POST via Transfer-Encoding: chunked, two hex');
171
172$t->{REQUEST}  = ( <<EOF
173POST /get-post-len.pl HTTP/1.1
174Host: www.example.org
175Connection: close
176Content-Type: application/x-www-form-urlencoded
177Transfer-Encoding: chunked
178
179a
1800123456789
1810
182Test-Trailer: testing
183
184EOF
185 );
186$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.1', 'HTTP-Status' => 200 } ];
187ok($tf->handle_http($t) == 0, 'POST via Transfer-Encoding: chunked, with trailer');
188
189$t->{REQUEST}  = ( <<EOF
190POST /get-post-len.pl HTTP/1.1
191Host: www.example.org
192Connection: close
193Content-Type: application/x-www-form-urlencoded
194Transfer-Encoding: chunked
195
196a; comment
1970123456789
1980
199
200EOF
201 );
202$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.1', 'HTTP-Status' => 200 } ];
203ok($tf->handle_http($t) == 0, 'POST via Transfer-Encoding: chunked, chunked header comment');
204
205$t->{REQUEST}  = ( <<EOF
206POST /get-post-len.pl HTTP/1.1
207Host: www.example.org
208Connection: close
209Content-Type: application/x-www-form-urlencoded
210Transfer-Encoding: chunked
211
212az
2130123456789
2140
215
216EOF
217 );
218$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.1', 'HTTP-Status' => 400 } ];
219ok($tf->handle_http($t) == 0, 'POST via Transfer-Encoding: chunked; bad chunked header');
220
221$t->{REQUEST}  = ( <<EOF
222POST /get-post-len.pl HTTP/1.1
223Host: www.example.org
224Connection: close
225Content-Type: application/x-www-form-urlencoded
226Transfer-Encoding: chunked
227
228a
2290123456789xxxxxxxx
2300
231
232EOF
233 );
234$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.1', 'HTTP-Status' => 400 } ];
235ok($tf->handle_http($t) == 0, 'POST via Transfer-Encoding: chunked; mismatch chunked header size and chunked data size');
236
237$t->{REQUEST}  = ( <<EOF
238POST /get-post-len.pl HTTP/1.1
239Host: www.example.org
240Connection: close
241Content-Type: application/x-www-form-urlencoded
242Transfer-Encoding: chunked
243
244a ; xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
2450123456789
2460
247
248EOF
249 );
250$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.1', 'HTTP-Status' => 400 } ];
251ok($tf->handle_http($t) == 0, 'POST via Transfer-Encoding: chunked; chunked header too long');
252
253## ranges
254
255$t->{REQUEST}  = ( <<EOF
256GET /12345.txt HTTP/1.0
257Host: 123.example.org
258Range: bytes=0-3
259EOF
260 );
261$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 206, 'HTTP-Content' => '1234' } ];
262ok($tf->handle_http($t) == 0, 'GET, Range 0-3');
263
264$t->{REQUEST}  = ( <<EOF
265GET /12345.txt HTTP/1.0
266Host: 123.example.org
267Range: bytes=-3
268EOF
269 );
270$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 206, 'HTTP-Content' => '45'."\n" } ];
271ok($tf->handle_http($t) == 0, 'GET, Range -3');
272
273$t->{REQUEST}  = ( <<EOF
274GET /12345.txt HTTP/1.0
275Host: 123.example.org
276Range: bytes=3-
277EOF
278 );
279$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 206, 'HTTP-Content' => '45'."\n" } ];
280ok($tf->handle_http($t) == 0, 'GET, Range 3-');
281
282$t->{REQUEST}  = ( <<EOF
283GET /12345.txt HTTP/1.0
284Host: 123.example.org
285Range: bytes=0-1,3-4
286EOF
287 );
288$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 206, 'HTTP-Content' => <<EOF
289\r
290--fkj49sn38dcn3\r
291Content-Range: bytes 0-1/6\r
292Content-Type: text/plain\r
293\r
29412\r
295--fkj49sn38dcn3\r
296Content-Range: bytes 3-4/6\r
297Content-Type: text/plain\r
298\r
29945\r
300--fkj49sn38dcn3--\r
301EOF
302 } ];
303ok($tf->handle_http($t) == 0, 'GET, Range 0-1,3-4');
304
305$t->{REQUEST}  = ( <<EOF
306GET /12345.txt HTTP/1.0
307Host: 123.example.org
308Range: bytes=0--
309EOF
310 );
311$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } ];
312ok($tf->handle_http($t) == 0, 'GET, Range 0--');
313
314$t->{REQUEST}  = ( <<EOF
315GET /12345.txt HTTP/1.0
316Host: 123.example.org
317Range: bytes=-2-3
318EOF
319 );
320$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } ];
321ok($tf->handle_http($t) == 0, 'GET, Range -2-3');
322
323$t->{REQUEST}  = ( <<EOF
324GET /12345.txt HTTP/1.0
325Host: 123.example.org
326Range: bytes=-0
327EOF
328 );
329$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 416, 'HTTP-Content' => <<EOF
330<?xml version="1.0" encoding="iso-8859-1"?>
331<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
332         "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
333<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
334 <head>
335  <title>416 Range Not Satisfiable</title>
336 </head>
337 <body>
338  <h1>416 Range Not Satisfiable</h1>
339 </body>
340</html>
341EOF
342 } ];
343ok($tf->handle_http($t) == 0, 'GET, Range -0');
344
345$t->{REQUEST}  = ( <<EOF
346GET /12345.txt HTTP/1.0
347Host: 123.example.org
348Range: bytes=25-
349EOF
350 );
351$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 416, 'HTTP-Content' => <<EOF
352<?xml version="1.0" encoding="iso-8859-1"?>
353<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
354         "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
355<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
356 <head>
357  <title>416 Range Not Satisfiable</title>
358 </head>
359 <body>
360  <h1>416 Range Not Satisfiable</h1>
361 </body>
362</html>
363EOF
364 } ];
365
366ok($tf->handle_http($t) == 0, 'GET, Range start out of range');
367
368
369$t->{REQUEST}  = ( <<EOF
370GET / HTTP/1.0
371Hsgfsdjf: asdfhdf
372hdhd: shdfhfdasd
373hfhr: jfghsdfg
374jfuuehdmn: sfdgjfdg
375jvcbzufdg: sgfdfg
376hrnvcnd: jfjdfg
377jfusfdngmd: gfjgfdusdfg
378nfj: jgfdjdfg
379jfue: jfdfdg
380EOF
381 );
382$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } ];
383ok($tf->handle_http($t) == 0, 'larger headers');
384
385
386$t->{REQUEST}  = ( <<EOF
387GET /range.pdf HTTP/1.0
388Range: bytes=0-
389EOF
390 );
391$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } ];
392ok($tf->handle_http($t) == 0, 'GET, Range with range-requests-disabled');
393
394$t->{REQUEST}  = ( <<EOF
395GET /12345.txt HTTP/1.0
396Host: 123.example.org
397Range: 0
398Range: bytes=0-3
399EOF
400 );
401$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => "12345\n" } ];
402ok($tf->handle_http($t) == 0, 'GET, Range invalid range-unit (first)');
403
404$t->{REQUEST}  = ( <<EOF
405GET /12345.txt HTTP/1.0
406Host: 123.example.org
407Range: bytes=0-3
408Range: 0
409EOF
410 );
411$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 206 } ];
412ok($tf->handle_http($t) == 0, 'GET, Range ignore invalid range (second)');
413
414$t->{REQUEST}  = ( <<EOF
415OPTIONS / HTTP/1.0
416Content-Length: 4
417
4181234
419EOF
420 );
421$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } ];
422ok($tf->handle_http($t) == 0, 'OPTIONS with Content-Length');
423
424$t->{REQUEST}  = ( <<EOF
425OPTIONS rtsp://221.192.134.146:80 RTSP/1.1
426Host: 221.192.134.146:80
427EOF
428 );
429$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 400 } ];
430ok($tf->handle_http($t) == 0, 'OPTIONS for RTSP');
431
432$t->{REQUEST}  = ( <<EOF
433GET /index.html HTTP/1.0
434If-Modified-Since: Sun, 01 Jan 2036 00:00:02 GMT
435If-Modified-Since: Sun, 01 Jan 2036 00:00:02 GMT
436EOF
437 );
438$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 304 } ];
439ok($tf->handle_http($t) == 0, 'Duplicate If-Mod-Since, with equal timestamps');
440
441$t->{REQUEST}  = ( "GET / HTTP/1.0\r\nIf-Modified-Since: \r\n\r\n" );
442$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } ];
443ok($tf->handle_http($t) == 0, 'empty If-Modified-Since');
444
445$t->{REQUEST}  = ( "GET / HTTP/1.0\r\nIf-Modified-Since: foobar\r\n\r\n" );
446$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } ];
447ok($tf->handle_http($t) == 0, 'broken If-Modified-Since');
448
449$t->{REQUEST}  = ( "GET / HTTP/1.0\r\nIf-Modified-Since: this string is too long to be a valid timestamp\r\n\r\n" );
450$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } ];
451ok($tf->handle_http($t) == 0, 'broken If-Modified-Since');
452
453
454$t->{REQUEST}  = ( <<EOF
455GET /index.html HTTP/1.0
456If-Modified-Since2: Sun, 01 Jan 2036 00:00:03 GMT
457If-Modified-Since: Sun, 01 Jan 2036 00:00:02 GMT
458EOF
459 );
460$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 304 } ];
461ok($tf->handle_http($t) == 0, 'Similar Headers (bug #1287)');
462
463$t->{REQUEST}  = ( <<EOF
464GET /index.html HTTP/1.0
465If-Modified-Since: Sun, 01 Jan 2036 00:00:02 GMT
466EOF
467 );
468$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 304, 'Content-Type' => 'text/html' } ];
469ok($tf->handle_http($t) == 0, 'If-Modified-Since');
470
471$t->{REQUEST}  = ( <<EOF
472GET /index.html HTTP/1.0
473If-Modified-Since: Sun, 01 Jan 2036 00:00:02 GMT
474EOF
475 );
476$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 304, '-Content-Length' => '' } ];
477ok($tf->handle_http($t) == 0, 'Status 304 has no Content-Length (#1002)');
478
479$t->{REQUEST}  = ( <<EOF
480GET /12345.txt HTTP/1.0
481Host: 123.example.org
482EOF
483 );
484$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => '12345'."\n", 'Content-Type' => 'text/plain' } ];
485$t->{SLOWREQUEST} = 1;
486ok($tf->handle_http($t) == 0, 'GET, slow \\r\\n\\r\\n (#2105)');
487undef $t->{SLOWREQUEST};
488
489print "\nPathinfo for static files\n";
490$t->{REQUEST}  = ( <<EOF
491GET /image.jpg/index.php HTTP/1.0
492EOF
493 );
494$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'Content-Type' => 'image/jpeg' } ];
495ok($tf->handle_http($t) == 0, 'static file accepting pathinfo by default');
496
497$t->{REQUEST}  = ( <<EOF
498GET /image.jpg/index.php HTTP/1.0
499Host: zzz.example.org
500EOF
501 );
502$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 403 } ];
503ok($tf->handle_http($t) == 0, 'static file with forbidden pathinfo');
504
505
506$t->{REQUEST}  = ( <<EOF
507GET /12345.txt HTTP/1.1
508Connection: ,close
509Host: 123.example.org
510EOF
511 );
512$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.1', 'HTTP-Status' => 200, 'HTTP-Content' => '12345'."\n", 'Content-Type' => 'text/plain', 'Connection' => 'close' } ];
513ok($tf->handle_http($t) == 0, 'Connection-header, leading comma');
514
515$t->{REQUEST}  = ( <<EOF
516GET /12345.txt HTTP/1.1
517Connection: close,,TE
518Host: 123.example.org
519EOF
520 );
521$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.1', 'HTTP-Status' => 200, 'HTTP-Content' => '12345'."\n", 'Content-Type' => 'text/plain', 'Connection' => 'close' } ];
522ok($tf->handle_http($t) == 0, 'Connection-header, no value between two commas');
523
524$t->{REQUEST}  = ( <<EOF
525GET /12345.txt HTTP/1.1
526Connection: close, ,TE
527Host: 123.example.org
528EOF
529 );
530$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.1', 'HTTP-Status' => 200, 'HTTP-Content' => '12345'."\n", 'Content-Type' => 'text/plain', 'Connection' => 'close' } ];
531ok($tf->handle_http($t) == 0, 'Connection-header, space between two commas');
532
533$t->{REQUEST}  = ( <<EOF
534GET /12345.txt HTTP/1.1
535Connection: close,
536Host: 123.example.org
537EOF
538 );
539$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.1', 'HTTP-Status' => 200, 'HTTP-Content' => '12345'."\n", 'Content-Type' => 'text/plain', 'Connection' => 'close' } ];
540ok($tf->handle_http($t) == 0, 'Connection-header, comma after value');
541
542$t->{REQUEST}  = ( <<EOF
543GET /12345.txt HTTP/1.1
544Connection: close,
545Host: 123.example.org
546EOF
547 );
548$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.1', 'HTTP-Status' => 200, 'HTTP-Content' => '12345'."\n", 'Content-Type' => 'text/plain', 'Connection' => 'close' } ];
549ok($tf->handle_http($t) == 0, 'Connection-header, comma and space after value');
550
551ok($tf->stop_proc == 0, "Stopping lighttpd");
552
553