Changeset 1946
- Timestamp:
- 08/18/2007 10:40:20 AM (1 year ago)
- Files:
-
- branches/lighttpd-1.4.x/NEWS (modified) (1 diff)
- branches/lighttpd-1.4.x/src/connections.c (modified) (2 diffs)
- branches/lighttpd-1.4.x/tests/LightyTest.pm (modified) (3 diffs)
- branches/lighttpd-1.4.x/tests/request.t (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/lighttpd-1.4.x/NEWS
r1944 r1946 19 19 * fixed too aggresive caching of nested conditionals (#41) 20 20 * fixed possible overflow in unix-socket path checks on BSD (#713) 21 * fixed extra Content-Length header on 1xx, 204 and 304 (#1002) 21 22 * removed config-check if passwd files exist (#1188) 22 23 branches/lighttpd-1.4.x/src/connections.c
r1924 r1946 506 506 case 206: /* write_queue is already prepared */ 507 507 break; 508 case 204: 508 509 case 205: /* class: header only */ 509 510 case 304: … … 525 526 off_t qlen = chunkqueue_length(con->write_queue); 526 527 527 /* if we have no content for a GET/PORT request, send Content-Length: 0 528 * if it is a HEAD request, don't generate a Content-Length as 529 * the backend might have already cut it off */ 530 if (qlen > 0 || con->request.http_method != HTTP_METHOD_HEAD) { 528 /** 529 * The Content-Length header only can be sent if we have content: 530 * - HEAD doesn't have a content-body (but have a content-length) 531 * - 1xx, 204 and 304 don't have a content-body (RFC 2616 Section 4.3) 532 * 533 * Otherwise generate a Content-Length header as chunked encoding is not 534 * available 535 */ 536 if ((con->http_status >= 100 && con->http_status < 200) || 537 con->http_status == 204 || 538 con->http_status == 304) { 539 /* no Content-Body, no Content-Length */ 540 } else if (qlen > 0) { 531 541 buffer_copy_off_t(srv->tmp_buf, chunkqueue_length(con->write_queue)); 532 542 branches/lighttpd-1.4.x/tests/LightyTest.pm
r1331 r1946 236 236 return -1; 237 237 } 238 } 239 240 if (defined $href->{'-HTTP-Content'}) { 238 } elsif (defined $href->{'-HTTP-Content'}) { 241 239 if (defined $resp_body && $resp_body ne '') { 242 240 diag(sprintf("body failed: expected empty body, got '%s'\n", $resp_body)); … … 246 244 247 245 foreach (keys %{ $href }) { 246 ## filter special keys 248 247 next if $_ eq 'HTTP-Protocol'; 249 248 next if $_ eq 'HTTP-Status'; … … 253 252 (my $k = $_) =~ tr/[A-Z]/[a-z]/; 254 253 255 my $no_val = 0; 254 my $verify_value = 1; 255 my $key_inverted = 0; 256 256 257 257 if (substr($k, 0, 1) eq '+') { 258 ## the key has to exist, but the value is ignored 258 259 $k = substr($k, 1); 259 $no_val = 1; 260 261 } 262 263 if (!defined $resp_hdr{$k}) { 264 diag(sprintf("required header '%s' is missing\n", $k)); 265 return -1; 266 } 267 268 if ($no_val == 0) { 260 $verify_value = 0; 261 } elsif (substr($k, 0, 1) eq '-') { 262 ## the key should NOT exist 263 $k = substr($k, 1); 264 $key_inverted = 1; 265 $verify_value = 0; ## skip the value check 266 } 267 268 if ($key_inverted) { 269 if (defined $resp_hdr{$k}) { 270 diag(sprintf("required header '%s' is missing\n", $k)); 271 return -1; 272 } 273 } else { 274 if (not defined $resp_hdr{$k}) { 275 diag(sprintf("required header '%s' is missing\n", $k)); 276 return -1; 277 } 278 } 279 280 if ($verify_value) { 269 281 if ($href->{$_} =~ /^\/(.+)\/$/) { 270 282 if ($resp_hdr{$k} !~ /$1/) { branches/lighttpd-1.4.x/tests/request.t
r1929 r1946 9 9 use strict; 10 10 use IO::Socket; 11 use Test::More tests => 4 0;11 use Test::More tests => 41; 12 12 use LightyTest; 13 13 … … 382 382 ok($tf->handle_http($t) == 0, 'If-Modified-Since'); 383 383 384 $t->{REQUEST} = ( <<EOF 385 GET /index.html HTTP/1.0 386 If-Modified-Since: Sun, 01 Jan 2100 00:00:02 GMT 387 EOF 388 ); 389 $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 304, '-Content-Length' => '' } ]; 390 ok($tf->handle_http($t) == 0, 'Status 304 has no Content-Length (#1002)'); 391 384 392 ok($tf->stop_proc == 0, "Stopping lighttpd"); 385 393

