2 Index: src/connections.c
3 ===================================================================
4 --- src/connections.c (.../tags/lighttpd-1.4.25)
5 +++ src/connections.c (.../branches/lighttpd-1.4.x)
10 - for (c = cq->first; !last_chunk && c; c = c->next) {
11 + for (c = cq->first; c; c = c->next) {
15 b.ptr = c->mem->ptr + c->offset;
16 b.used = c->mem->used - c->offset;
17 + if (b.used > 0) b.used--; /* buffer "used" includes terminating zero */
19 - for (i = 0; !last_chunk && i < b.used; i++) {
20 + for (i = 0; i < b.used; i++) {
22 - size_t have_chars = 0;
26 - /* we have to do a 4 char lookup */
27 - have_chars = b.used - i - 1;
29 + /* chec if \n\r\n follows */
32 + const char header_end[] = "\r\n\r\n";
33 + int header_end_match_pos = 1;
35 - if (have_chars >= 4) {
36 - /* all chars are in this buffer */
37 + for ( ; cc; cc = cc->next, j = 0 ) {
39 + bb.ptr = cc->mem->ptr + cc->offset;
40 + bb.used = cc->mem->used - cc->offset;
41 + if (bb.used > 0) bb.used--; /* buffer "used" includes terminating zero */
43 - if (0 == strncmp(b.ptr + i, "\r\n\r\n", 4)) {
46 - last_offset = i + 4;
47 + for ( ; j < bb.used; j++) {
53 - chunk *lookahead_chunk = c->next;
54 - size_t missing_chars;
55 - /* looks like the following chars are not in the same chunk */
57 - missing_chars = 4 - have_chars;
59 - if (lookahead_chunk && lookahead_chunk->type == MEM_CHUNK) {
60 - /* is the chunk long enough to contain the other chars ? */
62 - if (lookahead_chunk->mem->used > missing_chars) {
63 - if (0 == strncmp(b.ptr + i, "\r\n\r\n", have_chars) &&
64 - 0 == strncmp(lookahead_chunk->mem->ptr, "\r\n\r\n" + have_chars, missing_chars)) {
66 - last_chunk = lookahead_chunk;
67 - last_offset = missing_chars;
70 + if (ch == header_end[header_end_match_pos]) {
71 + header_end_match_pos++;
72 + if (4 == header_end_match_pos) {
75 + goto found_header_end;
78 - /* a splited \r \n */
94 Index: tests/request.t
95 ===================================================================
96 --- tests/request.t (.../tags/lighttpd-1.4.25)
97 +++ tests/request.t (.../branches/lighttpd-1.4.x)
102 -use Test::More tests => 41;
103 +use Test::More tests => 42;
106 my $tf = LightyTest->new();
108 $t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 304, '-Content-Length' => '' } ];
109 ok($tf->handle_http($t) == 0, 'Status 304 has no Content-Length (#1002)');
111 +$t->{REQUEST} = ( <<EOF
112 +GET /12345.txt HTTP/1.0
113 +Host: 123.example.org
116 +$t->{RESPONSE} = [ { 'HTTP-Protocol' => 'HTTP/1.0', 'HTTP-Status' => 200, 'HTTP-Content' => '12345'."\n", 'Content-Type' => 'text/plain' } ];
117 +$t->{SLOWREQUEST} = 1;
118 +ok($tf->handle_http($t) == 0, 'GET, slow \\r\\n\\r\\n (#2105)');
120 ok($tf->stop_proc == 0, "Stopping lighttpd");
122 Index: tests/LightyTest.pm
123 ===================================================================
124 --- tests/LightyTest.pm (.../tags/lighttpd-1.4.25)
125 +++ tests/LightyTest.pm (.../branches/lighttpd-1.4.x)
127 kill('TERM', $pid) or return -1;
128 return -1 if ($pid != waitpid($pid, 0));
130 - diag("Process not started, nothing to stop");
131 + diag("\nProcess not started, nothing to stop");
139 - diag("Timeout while trying to connect; killing child");
140 + diag("\nTimeout while trying to connect; killing child");
141 kill('TERM', $child);
144 @@ -128,10 +128,10 @@
145 } elsif (defined $ENV{"TRACEME"} && $ENV{"TRACEME"} eq 'valgrind') {
146 $cmdline = "valgrind --tool=memcheck --show-reachable=yes --leak-check=yes --log-file=valgrind ".$cmdline;
148 - # diag("starting lighttpd at :".$self->{PORT}.", cmdline: ".$cmdline );
149 + # diag("\nstarting lighttpd at :".$self->{PORT}.", cmdline: ".$cmdline );
151 if (not defined $child) {
152 - diag("Fork failed");
153 + diag("\nFork failed");
160 if (0 != $self->wait_for_port_with_proc($self->{PORT}, $child)) {
161 - diag(sprintf('The process %i is not up', $child));
162 + diag(sprintf('\nThe process %i is not up', $child));
168 my @request = $t->{REQUEST};
169 my @response = $t->{RESPONSE};
170 + my $slow = defined $t->{SLOWREQUEST};
171 my $is_debug = $ENV{"TRACE_HTTP"};
174 @@ -165,33 +166,56 @@
175 PeerPort => $self->{PORT});
177 if (not defined $remote) {
178 - diag("connect failed: $!");
179 + diag("\nconnect failed: $!");
183 $remote->autoflush(1);
185 - diag("sending request header to ".$host.":".$self->{PORT}) if $is_debug;
186 - foreach(@request) {
187 - # pipeline requests
191 + diag("\nsending request header to ".$host.":".$self->{PORT}) if $is_debug;
192 + foreach(@request) {
193 + # pipeline requests
197 - print $remote $_.$BLANK;
198 - diag("<< ".$_) if $is_debug;
199 + print $remote $_.$BLANK;
200 + diag("\n<< ".$_) if $is_debug;
202 + shutdown($remote, 1); # I've stopped writing data
204 + diag("\nsending request header to ".$host.":".$self->{PORT}) if $is_debug;
205 + foreach(@request) {
206 + # pipeline requests
212 + diag("<< ".$_."\n") if $is_debug;
213 + select(undef, undef, undef, 0.1);
214 + print $remote "\015";
215 + select(undef, undef, undef, 0.1);
216 + print $remote "\012";
217 + select(undef, undef, undef, 0.1);
218 + print $remote "\015";
219 + select(undef, undef, undef, 0.1);
220 + print $remote "\012";
221 + select(undef, undef, undef, 0.1);
225 - shutdown($remote, 1); # I've stopped writing data
226 - diag("... done") if $is_debug;
227 + diag("\n... done") if $is_debug;
231 - diag("receiving response") if $is_debug;
232 + diag("\nreceiving response") if $is_debug;
236 diag(">> ".$_) if $is_debug;
238 - diag("... done") if $is_debug;
239 + diag("\n... done") if $is_debug;
244 (my $line, $lines) = split($EOL, $lines, 2);
247 - last if(length($line) == 0);
248 + last if(!defined $line or length($line) == 0);
252 @@ -221,21 +245,21 @@
253 (my $h = $1) =~ tr/[A-Z]/[a-z]/;
255 if (defined $resp_hdr{$h}) {
256 -# diag(sprintf("header '%s' is duplicated: '%s' and '%s'\n",
257 +# diag(sprintf("\nheader '%s' is duplicated: '%s' and '%s'\n",
258 # $h, $resp_hdr{$h}, $2));
259 $resp_hdr{$h} .= ', '.$2;
264 - diag(sprintf("unexpected line '%s'\n", $line));
265 + diag(sprintf("\nunexpected line '%s'", $line));
271 if (not defined($resp_line)) {
272 - diag(sprintf("empty response\n"));
273 + diag(sprintf("\nempty response"));
277 @@ -259,29 +283,29 @@
279 if ($resp_line =~ /^(HTTP\/1\.[01]) ([0-9]{3}) .+$/) {
280 if ($href->{'HTTP-Protocol'} ne $1) {
281 - diag(sprintf("proto failed: expected '%s', got '%s'\n", $href->{'HTTP-Protocol'}, $1));
282 + diag(sprintf("\nproto failed: expected '%s', got '%s'", $href->{'HTTP-Protocol'}, $1));
285 if ($href->{'HTTP-Status'} ne $2) {
286 - diag(sprintf("status failed: expected '%s', got '%s'\n", $href->{'HTTP-Status'}, $2));
287 + diag(sprintf("\nstatus failed: expected '%s', got '%s'", $href->{'HTTP-Status'}, $2));
291 - diag(sprintf("unexpected resp_line '%s'\n", $resp_line));
292 + diag(sprintf("\nunexpected resp_line '%s'", $resp_line));
296 if (defined $href->{'HTTP-Content'}) {
297 $resp_body = "" unless defined $resp_body;
298 if ($href->{'HTTP-Content'} ne $resp_body) {
299 - diag(sprintf("body failed: expected '%s', got '%s'\n", $href->{'HTTP-Content'}, $resp_body));
300 + diag(sprintf("\nbody failed: expected '%s', got '%s'", $href->{'HTTP-Content'}, $resp_body));
305 if (defined $href->{'-HTTP-Content'}) {
306 if (defined $resp_body && $resp_body ne '') {
307 - diag(sprintf("body failed: expected empty body, got '%s'\n", $resp_body));
308 + diag(sprintf("\nbody failed: expected empty body, got '%s'", $resp_body));
312 @@ -309,12 +333,12 @@
315 if (defined $resp_hdr{$k}) {
316 - diag(sprintf("header '%s' MUST not be set\n", $k));
317 + diag(sprintf("\nheader '%s' MUST not be set", $k));
321 if (not defined $resp_hdr{$k}) {
322 - diag(sprintf("required header '%s' is missing\n", $k));
323 + diag(sprintf("\nrequired header '%s' is missing", $k));
327 @@ -322,12 +346,12 @@
329 if ($href->{$_} =~ /^\/(.+)\/$/) {
330 if ($resp_hdr{$k} !~ /$1/) {
331 - diag(sprintf("response-header failed: expected '%s', got '%s', regex: %s\n",
332 + diag(sprintf("\nresponse-header failed: expected '%s', got '%s', regex: %s",
333 $href->{$_}, $resp_hdr{$k}, $1));
336 } elsif ($href->{$_} ne $resp_hdr{$k}) {
337 - diag(sprintf("response-header failed: expected '%s', got '%s'\n",
338 + diag(sprintf("\nresponse-header failed: expected '%s', got '%s'",
339 $href->{$_}, $resp_hdr{$k}));
344 # we should have sucked up everything
345 if (defined $lines) {
346 - diag(sprintf("unexpected lines '%s'\n", $lines));
347 + diag(sprintf("\nunexpected lines '%s'", $lines));
352 my ($self, $binary, $port) = @_;
354 if (not defined $child) {
355 - diag("Couldn't fork\n");
356 + diag("\nCouldn't fork");
361 exec $binary or die($?);
363 if (0 != $self->wait_for_port_with_proc($port, $child)) {
364 - diag(sprintf('The process %i is not up (port %i, %s)', $child, $port, $binary));
365 + diag(sprintf("\nThe process %i is not up (port %i, %s)", $child, $port, $binary));
369 Index: tests/run-tests.pl
370 ===================================================================
371 --- tests/run-tests.pl (.../tags/lighttpd-1.4.25)
372 +++ tests/run-tests.pl (.../branches/lighttpd-1.4.x)
378 +runtests (sort @fs);
380 ===================================================================
382 ===================================================================
384 ===================================================================
385 --- NEWS (.../tags/lighttpd-1.4.25)
386 +++ NEWS (.../branches/lighttpd-1.4.x)
395 +- 1.4.25 - 2009-11-21
396 * mod_magnet: fix pairs() for normal tables and strings (fixes #1307)
397 * mod_magnet: add traceback for printing lua errors
398 * mod_rewrite: fix compile error if compiled without pcre
399 Index: CMakeLists.txt
400 ===================================================================