Changeset 1949
- Timestamp:
- 08/18/2007 11:42:13 AM (13 months ago)
- Location:
- trunk
- Files:
-
- 4 modified
-
NEWS (modified) (1 diff)
-
src/response.c (modified) (1 diff)
-
tests/LightyTest.pm (modified) (1 diff)
-
tests/request.t (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/NEWS
r1921 r1949 18 18 * fixed CONTENT_LENGTH = -1 in mod_cgi (#1276) 19 19 * fixed typecast of NULL on execl() (#1235) 20 * fixed extra Content-Length header on 1xx, 204 and 304 (#1002) 20 21 * fixed mysql server reconnects (#518) 21 22 -
trunk/src/response.c
r1868 r1949 49 49 if (con->response.transfer_encoding & HTTP_TRANSFER_ENCODING_CHUNKED) { 50 50 response_header_overwrite(srv, con, CONST_STR_LEN("Transfer-Encoding"), CONST_STR_LEN("chunked")); 51 allow_keep_alive = 1; 52 } else if ((con->http_status >= 100 && con->http_status < 200) || 53 con->http_status == 204 || 54 con->http_status == 304) { 55 /* 1xx, 204 and 304 never have a content-body -> 56 * never have a Content-Length and are always 57 * able to do keep-alive 58 */ 51 59 allow_keep_alive = 1; 52 60 } else if (con->response.content_length >= 0) { -
trunk/tests/LightyTest.pm
r1593 r1949 254 254 (my $k = $_) =~ tr/[A-Z]/[a-z]/; 255 255 256 my $no_val = 0; 256 my $verify_value = 1; 257 my $key_inverted = 0; 257 258 258 259 if (substr($k, 0, 1) eq '+') { 259 260 $k = substr($k, 1); 260 $no_val = 1; 261 262 } 263 264 if (!defined $resp_hdr{$k}) { 265 diag(sprintf("required header '%s' is missing\n", $k)); 266 return -1; 267 } 268 269 if ($no_val == 0) { 261 $verify_value = 0; 262 } elsif (substr($k, 0, 1) eq '-') { 263 ## the key should NOT exist 264 $k = substr($k, 1); 265 $key_inverted = 1; 266 $verify_value = 0; ## skip the value check 267 } 268 269 if ($key_inverted) { 270 if (defined $resp_hdr{$k}) { 271 diag(sprintf("header '%s' MUST not be set\n", $k)); 272 return -1; 273 } 274 } else { 275 if (not defined $resp_hdr{$k}) { 276 diag(sprintf("required header '%s' is missing\n", $k)); 277 return -1; 278 } 279 } 280 281 if ($verify_value) { 270 282 if ($href->{$_} =~ /^\/(.+)\/$/) { 271 283 if ($resp_hdr{$k} !~ /$1/) { -
trunk/tests/request.t
r1432 r1949 9 9 use strict; 10 10 use IO::Socket; 11 use Test::More tests => 34;11 use Test::More tests => 41; 12 12 use LightyTest; 13 13 … … 346 346 ok($tf->handle_http($t) == 0, 'HEAD with Content-Length'); 347 347 348 349 $t->{REQUEST} = ( <<EOF 350 GET / HTTP/1.0 351 If-Modified-Since: Sun, 1970 Jan 01 00:00:01 GMT 352 If-Modified-Since: Sun, 1970 Jan 01 00:00:01 GMT 353 EOF 354 ); 355 $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } ]; 348 $t->{REQUEST} = ( <<EOF 349 GET / HTTP/1.0 350 If-Modified-Since: Sun, 01 Jan 2100 00:00:02 GMT 351 If-Modified-Since: Sun, 01 Jan 2100 00:00:02 GMT 352 EOF 353 ); 354 $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 304} ]; 356 355 ok($tf->handle_http($t) == 0, 'Duplicate If-Mod-Since, with equal timestamps'); 357 356 357 $t->{REQUEST} = ( "GET / HTTP/1.0\r\nIf-Modified-Since: \0\r\n\r\n" ); 358 $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 400 } ]; 359 ok($tf->handle_http($t) == 0, 'invalid chars in Header values (bug #1286)'); 360 361 $t->{REQUEST} = ( "GET / HTTP/1.0\r\nIf-Modified-Since: \r\n\r\n" ); 362 $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } ]; 363 ok($tf->handle_http($t) == 0, 'empty If-Modified-Since'); 364 365 $t->{REQUEST} = ( "GET / HTTP/1.0\r\nIf-Modified-Since: foobar\r\n\r\n" ); 366 $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } ]; 367 ok($tf->handle_http($t) == 0, 'broken If-Modified-Since'); 368 369 $t->{REQUEST} = ( "GET / HTTP/1.0\r\nIf-Modified-Since: this string is too long to be a valid timestamp\r\n\r\n" ); 370 $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200 } ]; 371 ok($tf->handle_http($t) == 0, 'broken If-Modified-Since'); 372 373 374 $t->{REQUEST} = ( <<EOF 375 GET /index.html HTTP/1.0 376 If-Modified-Since2: Sun, 01 Jan 2100 00:00:03 GMT 377 If-Modified-Since: Sun, 01 Jan 2100 00:00:02 GMT 378 EOF 379 ); 380 $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 304 } ]; 381 ok($tf->handle_http($t) == 0, 'Similar Headers (bug #1287)'); 382 383 $t->{REQUEST} = ( <<EOF 384 GET /index.html HTTP/1.0 385 If-Modified-Since: Sun, 01 Jan 2100 00:00:02 GMT 386 EOF 387 ); 388 $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 304, 'Content-Type' => 'text/html' } ]; 389 ok($tf->handle_http($t) == 0, 'If-Modified-Since'); 390 391 $t->{REQUEST} = ( <<EOF 392 GET /index.html HTTP/1.0 393 If-Modified-Since: Sun, 01 Jan 2100 00:00:02 GMT 394 EOF 395 ); 396 $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 304, '-Content-Length' => '' } ]; 397 ok($tf->handle_http($t) == 0, 'Status 304 has no Content-Length (#1002)'); 398 358 399 ok($tf->stop_proc == 0, "Stopping lighttpd"); 359 400

