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 => 52; 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.1 257Host: 123.example.org 258Connection: close 259Range: bytes=0-3 260EOF 261 ); 262$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.1', 'HTTP-Status' => 206, 'HTTP-Content' => '1234' } ]; 263ok($tf->handle_http($t) == 0, 'GET, Range 0-3'); 264 265$t->{REQUEST} = ( <<EOF 266GET /12345.txt HTTP/1.1 267Host: 123.example.org 268Connection: close 269Range: bytes=-3 270EOF 271 ); 272$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.1', 'HTTP-Status' => 206, 'HTTP-Content' => '45'."\n" } ]; 273ok($tf->handle_http($t) == 0, 'GET, Range -3'); 274 275$t->{REQUEST} = ( <<EOF 276GET /12345.txt HTTP/1.1 277Host: 123.example.org 278Connection: close 279Range: bytes=3- 280EOF 281 ); 282$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.1', 'HTTP-Status' => 206, 'HTTP-Content' => '45'."\n" } ]; 283ok($tf->handle_http($t) == 0, 'GET, Range 3-'); 284 285$t->{REQUEST} = ( <<EOF 286GET /12345.txt HTTP/1.1 287Host: 123.example.org 288Connection: close 289Range: bytes=0-1,3-4 290EOF 291 ); 292$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.1', 'HTTP-Status' => 206, 'HTTP-Content' => '12345' } ]; 293ok($tf->handle_http($t) == 0, 'GET, Range 0-1,3-4 (ranges merged)'); 294 295$t->{REQUEST} = ( <<EOF 296GET /100.txt HTTP/1.1 297Host: 123.example.org 298Connection: close 299Range: bytes=0-1,97-98 300EOF 301 ); 302$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.1', 'HTTP-Status' => 206, 'HTTP-Content' => <<EOF 303\r 304--fkj49sn38dcn3\r 305Content-Range: bytes 0-1/100\r 306Content-Type: text/plain\r 307\r 30812\r 309--fkj49sn38dcn3\r 310Content-Range: bytes 97-98/100\r 311Content-Type: text/plain\r 312\r 313hi\r 314--fkj49sn38dcn3--\r 315EOF 316 } ]; 317ok($tf->handle_http($t) == 0, 'GET, Range 0-1,97-98 (ranges not merged)'); 318 319$t->{REQUEST} = ( <<EOF 320GET /12345.txt HTTP/1.1 321Host: 123.example.org 322Connection: close 323Range: bytes=0-- 324EOF 325 ); 326$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.1', 'HTTP-Status' => 200 } ]; 327ok($tf->handle_http($t) == 0, 'GET, Range 0--'); 328 329$t->{REQUEST} = ( <<EOF 330GET /12345.txt HTTP/1.1 331Host: 123.example.org 332Connection: close 333Range: bytes=-2-3 334EOF 335 ); 336$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.1', 'HTTP-Status' => 200 } ]; 337ok($tf->handle_http($t) == 0, 'GET, Range -2-3'); 338 339$t->{REQUEST} = ( <<EOF 340GET /12345.txt HTTP/1.1 341Host: 123.example.org 342Connection: close 343Range: bytes=-0 344EOF 345 ); 346$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.1', 'HTTP-Status' => 416, 'HTTP-Content' => <<EOF 347<?xml version="1.0" encoding="iso-8859-1"?> 348<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 349 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 350<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> 351 <head> 352 <title>416 Range Not Satisfiable</title> 353 </head> 354 <body> 355 <h1>416 Range Not Satisfiable</h1> 356 </body> 357</html> 358EOF 359 } ]; 360ok($tf->handle_http($t) == 0, 'GET, Range -0'); 361 362$t->{REQUEST} = ( <<EOF 363GET /12345.txt HTTP/1.1 364Host: 123.example.org 365Connection: close 366Range: bytes=25- 367EOF 368 ); 369$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.1', 'HTTP-Status' => 416, 'HTTP-Content' => <<EOF 370<?xml version="1.0" encoding="iso-8859-1"?> 371<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 372 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 373<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> 374 <head> 375 <title>416 Range Not Satisfiable</title> 376 </head> 377 <body> 378 <h1>416 Range Not Satisfiable</h1> 379 </body> 380</html> 381EOF 382 } ]; 383 384ok($tf->handle_http($t) == 0, 'GET, Range start out of range'); 385 386 387$t->{REQUEST} = ( <<EOF 388GET / HTTP/1.0 389Hsgfsdjf: asdfhdf 390hdhd: shdfhfdasd 391hfhr: jfghsdfg 392jfuuehdmn: sfdgjfdg 393jvcbzufdg: sgfdfg 394hrnvcnd: jfjdfg 395jfusfdngmd: gfjgfdusdfg 396nfj: jgfdjdfg 397jfue: jfdfdg 398EOF 399 ); 400$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } ]; 401ok($tf->handle_http($t) == 0, 'larger headers'); 402 403 404$t->{REQUEST} = ( <<EOF 405GET /range.pdf HTTP/1.1 406Host: 123.example.org 407Range: bytes=0- 408Connection: close 409EOF 410 ); 411$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.1', 'HTTP-Status' => 200 } ]; 412ok($tf->handle_http($t) == 0, 'GET, Range with range-requests-disabled'); 413 414$t->{REQUEST} = ( <<EOF 415GET /12345.txt HTTP/1.1 416Host: 123.example.org 417Connection: close 418Range: 0 419Range: bytes=0-3 420EOF 421 ); 422$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.1', 'HTTP-Status' => 200, 'HTTP-Content' => "12345\n" } ]; 423ok($tf->handle_http($t) == 0, 'GET, Range invalid range-unit (first)'); 424 425$t->{REQUEST} = ( <<EOF 426GET /12345.txt HTTP/1.1 427Host: 123.example.org 428Connection: close 429Range: bytes=0-3 430Range: 0 431EOF 432 ); 433$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.1', 'HTTP-Status' => 206 } ]; 434ok($tf->handle_http($t) == 0, 'GET, Range ignore invalid range (second)'); 435 436$t->{REQUEST} = ( <<EOF 437OPTIONS / HTTP/1.0 438Content-Length: 4 439 4401234 441EOF 442 ); 443$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } ]; 444ok($tf->handle_http($t) == 0, 'OPTIONS with Content-Length'); 445 446$t->{REQUEST} = ( <<EOF 447OPTIONS rtsp://221.192.134.146:80 RTSP/1.1 448Host: 221.192.134.146:80 449EOF 450 ); 451$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 400 } ]; 452ok($tf->handle_http($t) == 0, 'OPTIONS for RTSP'); 453 454$t->{REQUEST} = ( <<EOF 455GET /index.html HTTP/1.0 456If-Modified-Since: Sun, 01 Jan 2036 00:00:02 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, 'Duplicate If-Mod-Since, with equal timestamps'); 462 463$t->{REQUEST} = ( "GET / HTTP/1.0\r\nIf-Modified-Since: \r\n\r\n" ); 464$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } ]; 465ok($tf->handle_http($t) == 0, 'empty If-Modified-Since'); 466 467$t->{REQUEST} = ( "GET / HTTP/1.0\r\nIf-Modified-Since: foobar\r\n\r\n" ); 468$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } ]; 469ok($tf->handle_http($t) == 0, 'broken If-Modified-Since'); 470 471$t->{REQUEST} = ( "GET / HTTP/1.0\r\nIf-Modified-Since: this string is too long to be a valid timestamp\r\n\r\n" ); 472$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } ]; 473ok($tf->handle_http($t) == 0, 'broken If-Modified-Since'); 474 475 476$t->{REQUEST} = ( <<EOF 477GET /index.html HTTP/1.0 478If-Modified-Since2: Sun, 01 Jan 2036 00:00:03 GMT 479If-Modified-Since: Sun, 01 Jan 2036 00:00:02 GMT 480EOF 481 ); 482$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 304 } ]; 483ok($tf->handle_http($t) == 0, 'Similar Headers (bug #1287)'); 484 485$t->{REQUEST} = ( <<EOF 486GET /index.html HTTP/1.0 487If-Modified-Since: Sun, 01 Jan 2036 00:00:02 GMT 488EOF 489 ); 490$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 304, 'Content-Type' => 'text/html' } ]; 491ok($tf->handle_http($t) == 0, 'If-Modified-Since'); 492 493$t->{REQUEST} = ( <<EOF 494GET /index.html HTTP/1.0 495If-Modified-Since: Sun, 01 Jan 2036 00:00:02 GMT 496EOF 497 ); 498$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 304, '-Content-Length' => '' } ]; 499ok($tf->handle_http($t) == 0, 'Status 304 has no Content-Length (#1002)'); 500 501$t->{REQUEST} = ( <<EOF 502GET /12345.txt HTTP/1.0 503Host: 123.example.org 504EOF 505 ); 506$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => '12345'."\n", 'Content-Type' => 'text/plain' } ]; 507$t->{SLOWREQUEST} = 1; 508ok($tf->handle_http($t) == 0, 'GET, slow \\r\\n\\r\\n (#2105)'); 509undef $t->{SLOWREQUEST}; 510 511print "\nPathinfo for static files\n"; 512$t->{REQUEST} = ( <<EOF 513GET /image.jpg/index.php HTTP/1.0 514EOF 515 ); 516$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'Content-Type' => 'image/jpeg' } ]; 517ok($tf->handle_http($t) == 0, 'static file accepting pathinfo by default'); 518 519$t->{REQUEST} = ( <<EOF 520GET /image.jpg/index.php HTTP/1.0 521Host: zzz.example.org 522EOF 523 ); 524$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 403 } ]; 525ok($tf->handle_http($t) == 0, 'static file with forbidden pathinfo'); 526 527 528$t->{REQUEST} = ( <<EOF 529GET /12345.txt HTTP/1.1 530Connection: ,close 531Host: 123.example.org 532EOF 533 ); 534$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.1', 'HTTP-Status' => 200, 'HTTP-Content' => '12345'."\n", 'Content-Type' => 'text/plain', 'Connection' => 'close' } ]; 535ok($tf->handle_http($t) == 0, 'Connection-header, leading comma'); 536 537$t->{REQUEST} = ( <<EOF 538GET /12345.txt HTTP/1.1 539Connection: close,,TE 540Host: 123.example.org 541EOF 542 ); 543$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.1', 'HTTP-Status' => 200, 'HTTP-Content' => '12345'."\n", 'Content-Type' => 'text/plain', 'Connection' => 'close' } ]; 544ok($tf->handle_http($t) == 0, 'Connection-header, no value between two commas'); 545 546$t->{REQUEST} = ( <<EOF 547GET /12345.txt HTTP/1.1 548Connection: close, ,TE 549Host: 123.example.org 550EOF 551 ); 552$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.1', 'HTTP-Status' => 200, 'HTTP-Content' => '12345'."\n", 'Content-Type' => 'text/plain', 'Connection' => 'close' } ]; 553ok($tf->handle_http($t) == 0, 'Connection-header, space between two commas'); 554 555$t->{REQUEST} = ( <<EOF 556GET /12345.txt HTTP/1.1 557Connection: close, 558Host: 123.example.org 559EOF 560 ); 561$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.1', 'HTTP-Status' => 200, 'HTTP-Content' => '12345'."\n", 'Content-Type' => 'text/plain', 'Connection' => 'close' } ]; 562ok($tf->handle_http($t) == 0, 'Connection-header, comma after value'); 563 564$t->{REQUEST} = ( <<EOF 565GET /12345.txt HTTP/1.1 566Connection: close, 567Host: 123.example.org 568EOF 569 ); 570$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.1', 'HTTP-Status' => 200, 'HTTP-Content' => '12345'."\n", 'Content-Type' => 'text/plain', 'Connection' => 'close' } ]; 571ok($tf->handle_http($t) == 0, 'Connection-header, comma and space after value'); 572 573ok($tf->stop_proc == 0, "Stopping lighttpd"); 574 575