[autobuild] allow sendfile() in cross-compile (fixes #2836)
[lighttpd.git] / tests / request.t
blob70f5ee5f08c6dde9fb5686ca4915d78a51a8abaa
1 #!/usr/bin/env perl
2 BEGIN {
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;
9 use strict;
10 use IO::Socket;
11 use Test::More tests => 59;
12 use LightyTest;
14 my $tf = LightyTest->new();
15 my $t;
17 ok($tf->start_proc == 0, "Starting lighttpd") or die();
19 ## Basic Request-Handling
21 $t->{REQUEST} = ( <<EOF
22 GET /foobar HTTP/1.0
23 EOF
25 $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 404 } ];
26 ok($tf->handle_http($t) == 0, 'file not found');
28 $t->{REQUEST} = ( <<EOF
29 GET /foobar?foobar HTTP/1.0
30 EOF
32 $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 404 } ];
33 ok($tf->handle_http($t) == 0, 'file not found + querystring');
35 $t->{REQUEST} = ( <<EOF
36 GET /12345.txt HTTP/1.0
37 Host: 123.example.org
38 EOF
40 $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => '12345'."\n", 'Content-Type' => 'text/plain' } ];
41 ok($tf->handle_http($t) == 0, 'GET, content == 12345, mimetype text/plain');
43 $t->{REQUEST} = ( <<EOF
44 GET /12345.html HTTP/1.0
45 Host: 123.example.org
46 EOF
48 $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => '12345'."\n", 'Content-Type' => 'text/html' } ];
49 ok($tf->handle_http($t) == 0, 'GET, content == 12345, mimetype text/html');
51 $t->{REQUEST} = ( <<EOF
52 GET /dummyfile.bla HTTP/1.0
53 Host: 123.example.org
54 EOF
56 $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => '12345'."\n", 'Content-Type' => 'application/octet-stream' } ];
57 ok($tf->handle_http($t) == 0, 'GET, content == 12345, mimetype application/octet-stream');
59 $t->{REQUEST} = ( <<EOF
60 POST / HTTP/1.0
61 EOF
63 $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 411 } ];
64 ok($tf->handle_http($t) == 0, 'POST request, no Content-Length');
67 $t->{REQUEST} = ( <<EOF
68 POST / HTTP/1.0
69 Content-type: application/x-www-form-urlencoded
70 Content-length: 0
71 EOF
73 $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } ];
74 ok($tf->handle_http($t) == 0, 'POST request, empty request-body');
76 $t->{REQUEST} = ( <<EOF
77 HEAD / HTTP/1.0
78 EOF
80 $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, '-HTTP-Content' => ''} ];
81 ok($tf->handle_http($t) == 0, 'HEAD request, no content');
83 $t->{REQUEST} = ( <<EOF
84 HEAD /12345.html HTTP/1.0
85 Host: 123.example.org
86 EOF
88 $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, '-HTTP-Content' => '', 'Content-Type' => 'text/html', 'Content-Length' => '6'} ];
89 ok($tf->handle_http($t) == 0, 'HEAD request, mimetype text/html, content-length');
91 $t->{REQUEST} = ( <<EOF
92 HEAD http://123.example.org/12345.html HTTP/1.1
93 Connection: close
94 EOF
96 $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.1', 'HTTP-Status' => 200, '-HTTP-Content' => '', 'Content-Type' => 'text/html', 'Content-Length' => '6'} ];
97 ok($tf->handle_http($t) == 0, 'Hostname in first line, HTTP/1.1');
99 $t->{REQUEST} = ( <<EOF
100 HEAD https://123.example.org/12345.html HTTP/1.0
103 $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, '-HTTP-Content' => '', 'Content-Type' => 'text/html', 'Content-Length' => '6'} ];
104 ok($tf->handle_http($t) == 0, 'Hostname in first line as https url');
106 $t->{REQUEST} = ( <<EOF
107 HEAD /foobar?foobar HTTP/1.0
110 $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 404, '-HTTP-Content' => '' } ];
111 ok($tf->handle_http($t) == 0, 'HEAD request, file-not-found, query-string');
113 # (expect 200 OK instead of 100 Continue since request body sent with request)
114 # (if we waited to send request body, would expect 100 Continue, first)
115 $t->{REQUEST} = ( <<EOF
116 POST /get-post-len.pl HTTP/1.1
117 Host: www.example.org
118 Connection: close
119 Content-Type: application/x-www-form-urlencoded
120 Content-Length: 4
121 Expect: 100-continue
126 $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.1', 'HTTP-Status' => 200 } ];
127 ok($tf->handle_http($t) == 0, 'Continue, Expect');
129 # note Transfer-Encoding: chunked tests will fail with 411 Length Required if
130 # server.stream-request-body != 0 in lighttpd.conf
131 $t->{REQUEST} = ( <<EOF
132 POST /get-post-len.pl HTTP/1.1
133 Host: www.example.org
134 Connection: close
135 Content-Type: application/x-www-form-urlencoded
136 Transfer-Encoding: chunked
139 0123456789
144 $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.1', 'HTTP-Status' => 200 } ];
145 ok($tf->handle_http($t) == 0, 'POST via Transfer-Encoding: chunked, lc hex');
147 $t->{REQUEST} = ( <<EOF
148 POST /get-post-len.pl HTTP/1.1
149 Host: www.example.org
150 Connection: close
151 Content-Type: application/x-www-form-urlencoded
152 Transfer-Encoding: chunked
155 0123456789
160 $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.1', 'HTTP-Status' => 200 } ];
161 ok($tf->handle_http($t) == 0, 'POST via Transfer-Encoding: chunked, uc hex');
163 $t->{REQUEST} = ( <<EOF
164 POST /get-post-len.pl HTTP/1.1
165 Host: www.example.org
166 Connection: close
167 Content-Type: application/x-www-form-urlencoded
168 Transfer-Encoding: chunked
171 0123456789
173 Test-Trailer: testing
177 $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.1', 'HTTP-Status' => 200 } ];
178 ok($tf->handle_http($t) == 0, 'POST via Transfer-Encoding: chunked, with trailer');
180 $t->{REQUEST} = ( <<EOF
181 POST /get-post-len.pl HTTP/1.1
182 Host: www.example.org
183 Connection: close
184 Content-Type: application/x-www-form-urlencoded
185 Transfer-Encoding: chunked
187 a; comment
188 0123456789
193 $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.1', 'HTTP-Status' => 200 } ];
194 ok($tf->handle_http($t) == 0, 'POST via Transfer-Encoding: chunked, chunked header comment');
196 $t->{REQUEST} = ( <<EOF
197 POST /get-post-len.pl HTTP/1.1
198 Host: www.example.org
199 Connection: close
200 Content-Type: application/x-www-form-urlencoded
201 Transfer-Encoding: chunked
204 0123456789
209 $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.1', 'HTTP-Status' => 400 } ];
210 ok($tf->handle_http($t) == 0, 'POST via Transfer-Encoding: chunked; bad chunked header');
212 $t->{REQUEST} = ( <<EOF
213 POST /get-post-len.pl HTTP/1.1
214 Host: www.example.org
215 Connection: close
216 Content-Type: application/x-www-form-urlencoded
217 Transfer-Encoding: chunked
220 0123456789xxxxxxxx
225 $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.1', 'HTTP-Status' => 400 } ];
226 ok($tf->handle_http($t) == 0, 'POST via Transfer-Encoding: chunked; mismatch chunked header size and chunked data size');
228 $t->{REQUEST} = ( <<EOF
229 POST /get-post-len.pl HTTP/1.1
230 Host: www.example.org
231 Connection: close
232 Content-Type: application/x-www-form-urlencoded
233 Transfer-Encoding: chunked
235 a ; xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
236 0123456789
241 $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.1', 'HTTP-Status' => 400 } ];
242 ok($tf->handle_http($t) == 0, 'POST via Transfer-Encoding: chunked; chunked header too long');
244 ## ranges
246 $t->{REQUEST} = ( <<EOF
247 GET /12345.txt HTTP/1.0
248 Host: 123.example.org
249 Range: bytes=0-3
252 $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 206, 'HTTP-Content' => '1234' } ];
253 ok($tf->handle_http($t) == 0, 'GET, Range 0-3');
255 $t->{REQUEST} = ( <<EOF
256 GET /12345.txt HTTP/1.0
257 Host: 123.example.org
258 Range: bytes=-3
261 $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 206, 'HTTP-Content' => '45'."\n" } ];
262 ok($tf->handle_http($t) == 0, 'GET, Range -3');
264 $t->{REQUEST} = ( <<EOF
265 GET /12345.txt HTTP/1.0
266 Host: 123.example.org
267 Range: bytes=3-
270 $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 206, 'HTTP-Content' => '45'."\n" } ];
271 ok($tf->handle_http($t) == 0, 'GET, Range 3-');
273 $t->{REQUEST} = ( <<EOF
274 GET /12345.txt HTTP/1.0
275 Host: 123.example.org
276 Range: bytes=0-1,3-4
279 $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 206, 'HTTP-Content' => <<EOF
281 --fkj49sn38dcn3\r
282 Content-Range: bytes 0-1/6\r
283 Content-Type: text/plain\r
285 12\r
286 --fkj49sn38dcn3\r
287 Content-Range: bytes 3-4/6\r
288 Content-Type: text/plain\r
290 45\r
291 --fkj49sn38dcn3--\r
293 } ];
294 ok($tf->handle_http($t) == 0, 'GET, Range 0-1,3-4');
296 $t->{REQUEST} = ( <<EOF
297 GET /12345.txt HTTP/1.0
298 Host: 123.example.org
299 Range: bytes=0--
302 $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } ];
303 ok($tf->handle_http($t) == 0, 'GET, Range 0--');
305 $t->{REQUEST} = ( <<EOF
306 GET /12345.txt HTTP/1.0
307 Host: 123.example.org
308 Range: bytes=-2-3
311 $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } ];
312 ok($tf->handle_http($t) == 0, 'GET, Range -2-3');
314 $t->{REQUEST} = ( <<EOF
315 GET /12345.txt HTTP/1.0
316 Host: 123.example.org
317 Range: bytes=-0
320 $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 416, 'HTTP-Content' => <<EOF
321 <?xml version="1.0" encoding="iso-8859-1"?>
322 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
323 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
324 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
325 <head>
326 <title>416 - Requested Range Not Satisfiable</title>
327 </head>
328 <body>
329 <h1>416 - Requested Range Not Satisfiable</h1>
330 </body>
331 </html>
333 } ];
334 ok($tf->handle_http($t) == 0, 'GET, Range -0');
336 $t->{REQUEST} = ( <<EOF
337 GET /12345.txt HTTP/1.0
338 Host: 123.example.org
339 Range: bytes=25-
342 $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 416, 'HTTP-Content' => <<EOF
343 <?xml version="1.0" encoding="iso-8859-1"?>
344 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
345 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
346 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
347 <head>
348 <title>416 - Requested Range Not Satisfiable</title>
349 </head>
350 <body>
351 <h1>416 - Requested Range Not Satisfiable</h1>
352 </body>
353 </html>
355 } ];
357 ok($tf->handle_http($t) == 0, 'GET, Range start out of range');
360 $t->{REQUEST} = ( <<EOF
361 GET / HTTP/1.0
362 Hsgfsdjf: asdfhdf
363 hdhd: shdfhfdasd
364 hfhr: jfghsdfg
365 jfuuehdmn: sfdgjfdg
366 jvcbzufdg: sgfdfg
367 hrnvcnd: jfjdfg
368 jfusfdngmd: gfjgfdusdfg
369 nfj: jgfdjdfg
370 jfue: jfdfdg
373 $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } ];
374 ok($tf->handle_http($t) == 0, 'larger headers');
377 $t->{REQUEST} = ( <<EOF
378 GET / HTTP/1.0
379 Host: www.example.org
380 Host: 123.example.org
383 $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 400 } ];
384 ok($tf->handle_http($t) == 0, 'Duplicate Host headers, Bug #25');
387 $t->{REQUEST} = ( <<EOF
388 GET / HTTP/1.0
389 Content-Length: 5
390 Content-Length: 4
393 $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 400 } ];
394 ok($tf->handle_http($t) == 0, 'Duplicate Content-Length headers');
396 $t->{REQUEST} = ( <<EOF
397 GET / HTTP/1.0
398 Content-Type: 5
399 Content-Type: 4
402 $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 400 } ];
403 ok($tf->handle_http($t) == 0, 'Duplicate Content-Type headers');
405 $t->{REQUEST} = ( <<EOF
406 GET / HTTP/1.0
407 Range: bytes=5-6
408 Range: bytes=5-9
411 $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 400 } ];
412 ok($tf->handle_http($t) == 0, 'Duplicate Range headers');
414 $t->{REQUEST} = ( <<EOF
415 GET / HTTP/1.0
416 If-None-Match: 5
417 If-None-Match: 4
420 $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } ];
421 ok($tf->handle_http($t) == 0, 'Duplicate If-None-Match headers');
423 $t->{REQUEST} = ( <<EOF
424 GET / HTTP/1.0
425 If-Modified-Since: 5
426 If-Modified-Since: 4
429 $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 400 } ];
430 ok($tf->handle_http($t) == 0, 'Duplicate If-Modified-Since headers');
432 $t->{REQUEST} = ( <<EOF
433 GET /range.pdf HTTP/1.0
434 Range: bytes=0-
437 $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } ];
438 ok($tf->handle_http($t) == 0, 'GET, Range with range-requests-disabled');
440 $t->{REQUEST} = ( <<EOF
441 GET / HTTP/1.0
442 Content-Length: 4
444 1234
447 $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 400 } ];
448 ok($tf->handle_http($t) == 0, 'GET with Content-Length');
450 $t->{REQUEST} = ( <<EOF
451 OPTIONS / HTTP/1.0
452 Content-Length: 4
454 1234
457 $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } ];
458 ok($tf->handle_http($t) == 0, 'OPTIONS with Content-Length');
460 $t->{REQUEST} = ( <<EOF
461 OPTIONS rtsp://221.192.134.146:80 RTSP/1.1
462 Host: 221.192.134.146:80
465 $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 400 } ];
466 ok($tf->handle_http($t) == 0, 'OPTIONS for RTSP');
468 $t->{REQUEST} = ( <<EOF
469 HEAD / HTTP/1.0
470 Content-Length: 4
472 1234
475 $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 400 } ];
476 ok($tf->handle_http($t) == 0, 'HEAD with Content-Length');
478 $t->{REQUEST} = ( <<EOF
479 GET /index.html HTTP/1.0
480 If-Modified-Since: Sun, 01 Jan 2036 00:00:02 GMT
481 If-Modified-Since: Sun, 01 Jan 2036 00:00:02 GMT
484 $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 304 } ];
485 ok($tf->handle_http($t) == 0, 'Duplicate If-Mod-Since, with equal timestamps');
487 $t->{REQUEST} = ( "GET / HTTP/1.0\r\nIf-Modified-Since: \0\r\n\r\n" );
488 $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 400 } ];
489 ok($tf->handle_http($t) == 0, 'invalid chars in Header values (bug #1286)');
491 $t->{REQUEST} = ( "GET / HTTP/1.0\r\nIf-Modified-Since: \r\n\r\n" );
492 $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } ];
493 ok($tf->handle_http($t) == 0, 'empty If-Modified-Since');
495 $t->{REQUEST} = ( "GET / HTTP/1.0\r\nIf-Modified-Since: foobar\r\n\r\n" );
496 $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } ];
497 ok($tf->handle_http($t) == 0, 'broken If-Modified-Since');
499 $t->{REQUEST} = ( "GET / HTTP/1.0\r\nIf-Modified-Since: this string is too long to be a valid timestamp\r\n\r\n" );
500 $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } ];
501 ok($tf->handle_http($t) == 0, 'broken If-Modified-Since');
504 $t->{REQUEST} = ( <<EOF
505 GET /index.html HTTP/1.0
506 If-Modified-Since2: Sun, 01 Jan 2036 00:00:03 GMT
507 If-Modified-Since: Sun, 01 Jan 2036 00:00:02 GMT
510 $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 304 } ];
511 ok($tf->handle_http($t) == 0, 'Similar Headers (bug #1287)');
513 $t->{REQUEST} = ( <<EOF
514 GET /index.html HTTP/1.0
515 If-Modified-Since: Sun, 01 Jan 2036 00:00:02 GMT
518 $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 304, 'Content-Type' => 'text/html' } ];
519 ok($tf->handle_http($t) == 0, 'If-Modified-Since');
521 $t->{REQUEST} = ( <<EOF
522 GET /index.html HTTP/1.0
523 If-Modified-Since: Sun, 01 Jan 2036 00:00:02 GMT
526 $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 304, '-Content-Length' => '' } ];
527 ok($tf->handle_http($t) == 0, 'Status 304 has no Content-Length (#1002)');
529 $t->{REQUEST} = ( <<EOF
530 GET /12345.txt HTTP/1.0
531 Host: 123.example.org
534 $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => '12345'."\n", 'Content-Type' => 'text/plain' } ];
535 $t->{SLOWREQUEST} = 1;
536 ok($tf->handle_http($t) == 0, 'GET, slow \\r\\n\\r\\n (#2105)');
537 undef $t->{SLOWREQUEST};
539 print "\nPathinfo for static files\n";
540 $t->{REQUEST} = ( <<EOF
541 GET /image.jpg/index.php HTTP/1.0
544 $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'Content-Type' => 'image/jpeg' } ];
545 ok($tf->handle_http($t) == 0, 'static file accepting pathinfo by default');
547 $t->{REQUEST} = ( <<EOF
548 GET /image.jpg/index.php HTTP/1.0
549 Host: zzz.example.org
552 $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 403 } ];
553 ok($tf->handle_http($t) == 0, 'static file with forbidden pathinfo');
556 print "\nConnection header\n";
557 $t->{REQUEST} = ( <<EOF
558 GET /12345.txt HTTP/1.1
559 Connection : close
560 Host: 123.example.org
563 $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.1', 'HTTP-Status' => 200, 'HTTP-Content' => '12345'."\n", 'Content-Type' => 'text/plain', 'Connection' => 'close' } ];
564 ok($tf->handle_http($t) == 0, 'Connection-header, spaces before ":"');
566 $t->{REQUEST} = ( <<EOF
567 GET /12345.txt HTTP/1.1
568 Connection: ,close
569 Host: 123.example.org
572 $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.1', 'HTTP-Status' => 200, 'HTTP-Content' => '12345'."\n", 'Content-Type' => 'text/plain', 'Connection' => 'close' } ];
573 ok($tf->handle_http($t) == 0, 'Connection-header, leading comma');
575 $t->{REQUEST} = ( <<EOF
576 GET /12345.txt HTTP/1.1
577 Connection: close,,TE
578 Host: 123.example.org
581 $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.1', 'HTTP-Status' => 200, 'HTTP-Content' => '12345'."\n", 'Content-Type' => 'text/plain', 'Connection' => 'close' } ];
582 ok($tf->handle_http($t) == 0, 'Connection-header, no value between two commas');
584 $t->{REQUEST} = ( <<EOF
585 GET /12345.txt HTTP/1.1
586 Connection: close, ,TE
587 Host: 123.example.org
590 $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.1', 'HTTP-Status' => 200, 'HTTP-Content' => '12345'."\n", 'Content-Type' => 'text/plain', 'Connection' => 'close' } ];
591 ok($tf->handle_http($t) == 0, 'Connection-header, space between two commas');
593 $t->{REQUEST} = ( <<EOF
594 GET /12345.txt HTTP/1.1
595 Connection: close,
596 Host: 123.example.org
599 $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.1', 'HTTP-Status' => 200, 'HTTP-Content' => '12345'."\n", 'Content-Type' => 'text/plain', 'Connection' => 'close' } ];
600 ok($tf->handle_http($t) == 0, 'Connection-header, comma after value');
602 $t->{REQUEST} = ( <<EOF
603 GET /12345.txt HTTP/1.1
604 Connection: close,
605 Host: 123.example.org
608 $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.1', 'HTTP-Status' => 200, 'HTTP-Content' => '12345'."\n", 'Content-Type' => 'text/plain', 'Connection' => 'close' } ];
609 ok($tf->handle_http($t) == 0, 'Connection-header, comma and space after value');
611 ok($tf->stop_proc == 0, "Stopping lighttpd");