]> git.pld-linux.org Git - packages/lighttpd.git/blame - lighttpd-branch.diff
- release 4
[packages/lighttpd.git] / lighttpd-branch.diff
CommitLineData
9d2ca5f8
ER
1# Revision 2698
2Index: src/connections.c
3===================================================================
4--- src/connections.c (.../tags/lighttpd-1.4.25)
5+++ src/connections.c (.../branches/lighttpd-1.4.x)
6@@ -945,62 +945,50 @@
7 last_chunk = NULL;
8 last_offset = 0;
9
10- for (c = cq->first; !last_chunk && c; c = c->next) {
11+ for (c = cq->first; c; c = c->next) {
12 buffer b;
13 size_t i;
14
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 */
18
19- for (i = 0; !last_chunk && i < b.used; i++) {
20+ for (i = 0; i < b.used; i++) {
21 char ch = b.ptr[i];
22- size_t have_chars = 0;
23
24- switch (ch) {
25- case '\r':
26- /* we have to do a 4 char lookup */
27- have_chars = b.used - i - 1;
28+ if ('\r' == ch) {
29+ /* chec if \n\r\n follows */
30+ size_t j = i+1;
31+ chunk *cc = c;
32+ const char header_end[] = "\r\n\r\n";
33+ int header_end_match_pos = 1;
34
35- if (have_chars >= 4) {
36- /* all chars are in this buffer */
37+ for ( ; cc; cc = cc->next, j = 0 ) {
38+ buffer bb;
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 */
42
43- if (0 == strncmp(b.ptr + i, "\r\n\r\n", 4)) {
44- /* found */
45- last_chunk = c;
46- last_offset = i + 4;
47+ for ( ; j < bb.used; j++) {
48+ ch = bb.ptr[j];
49
50- break;
51- }
52- } else {
53- chunk *lookahead_chunk = c->next;
54- size_t missing_chars;
55- /* looks like the following chars are not in the same chunk */
56-
57- missing_chars = 4 - have_chars;
58-
59- if (lookahead_chunk && lookahead_chunk->type == MEM_CHUNK) {
60- /* is the chunk long enough to contain the other chars ? */
61-
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)) {
65-
66- last_chunk = lookahead_chunk;
67- last_offset = missing_chars;
68-
69- break;
70+ if (ch == header_end[header_end_match_pos]) {
71+ header_end_match_pos++;
72+ if (4 == header_end_match_pos) {
73+ last_chunk = cc;
74+ last_offset = j+1;
75+ goto found_header_end;
76 }
77 } else {
78- /* a splited \r \n */
79- break;
80+ goto reset_search;
81 }
82 }
83 }
84-
85- break;
86 }
87+reset_search: ;
88 }
89 }
90+found_header_end:
91
92 /* found */
93 if (last_chunk) {
94Index: tests/request.t
95===================================================================
96--- tests/request.t (.../tags/lighttpd-1.4.25)
97+++ tests/request.t (.../branches/lighttpd-1.4.x)
98@@ -8,7 +8,7 @@
99
100 use strict;
101 use IO::Socket;
102-use Test::More tests => 41;
103+use Test::More tests => 42;
104 use LightyTest;
105
106 my $tf = LightyTest->new();
107@@ -389,5 +389,14 @@
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)');
110
111+$t->{REQUEST} = ( <<EOF
112+GET /12345.txt HTTP/1.0
113+Host: 123.example.org
114+EOF
115+ );
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)');
119+
120 ok($tf->stop_proc == 0, "Stopping lighttpd");
121
122Index: tests/LightyTest.pm
123===================================================================
124--- tests/LightyTest.pm (.../tags/lighttpd-1.4.25)
125+++ tests/LightyTest.pm (.../branches/lighttpd-1.4.x)
126@@ -76,7 +76,7 @@
127 kill('TERM', $pid) or return -1;
128 return -1 if ($pid != waitpid($pid, 0));
129 } else {
130- diag("Process not started, nothing to stop");
131+ diag("\nProcess not started, nothing to stop");
132 return -1;
133 }
134
135@@ -98,7 +98,7 @@
136 return -1;
137 }
138 if (0 >= $timeout) {
139- diag("Timeout while trying to connect; killing child");
140+ diag("\nTimeout while trying to connect; killing child");
141 kill('TERM', $child);
142 return -1;
143 }
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;
147 }
148- # diag("starting lighttpd at :".$self->{PORT}.", cmdline: ".$cmdline );
149+ # diag("\nstarting lighttpd at :".$self->{PORT}.", cmdline: ".$cmdline );
150 my $child = fork();
151 if (not defined $child) {
152- diag("Fork failed");
153+ diag("\nFork failed");
154 return -1;
155 }
156 if ($child == 0) {
157@@ -139,7 +139,7 @@
158 }
159
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));
163 return -1;
164 }
165
166@@ -157,6 +157,7 @@
167
168 my @request = $t->{REQUEST};
169 my @response = $t->{RESPONSE};
170+ my $slow = defined $t->{SLOWREQUEST};
171 my $is_debug = $ENV{"TRACE_HTTP"};
172
173 my $remote =
174@@ -165,33 +166,56 @@
175 PeerPort => $self->{PORT});
176
177 if (not defined $remote) {
178- diag("connect failed: $!");
179+ diag("\nconnect failed: $!");
180 return -1;
181 }
182
183 $remote->autoflush(1);
184
185- diag("sending request header to ".$host.":".$self->{PORT}) if $is_debug;
186- foreach(@request) {
187- # pipeline requests
188- s/\r//g;
189- s/\n/$EOL/g;
190+ if (!$slow) {
191+ diag("\nsending request header to ".$host.":".$self->{PORT}) if $is_debug;
192+ foreach(@request) {
193+ # pipeline requests
194+ s/\r//g;
195+ s/\n/$EOL/g;
196
197- print $remote $_.$BLANK;
198- diag("<< ".$_) if $is_debug;
199+ print $remote $_.$BLANK;
200+ diag("\n<< ".$_) if $is_debug;
201+ }
202+ shutdown($remote, 1); # I've stopped writing data
203+ } else {
204+ diag("\nsending request header to ".$host.":".$self->{PORT}) if $is_debug;
205+ foreach(@request) {
206+ # pipeline requests
207+ chomp;
208+ s/\r//g;
209+ s/\n/$EOL/g;
210+
211+ print $remote $_;
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);
222+ }
223+
224 }
225- shutdown($remote, 1); # I've stopped writing data
226- diag("... done") if $is_debug;
227+ diag("\n... done") if $is_debug;
228
229 my $lines = "";
230
231- diag("receiving response") if $is_debug;
232+ diag("\nreceiving response") if $is_debug;
233 # read everything
234 while(<$remote>) {
235 $lines .= $_;
236 diag(">> ".$_) if $is_debug;
237 }
238- diag("... done") if $is_debug;
239+ diag("\n... done") if $is_debug;
240
241 close $remote;
242
243@@ -209,7 +233,7 @@
244 (my $line, $lines) = split($EOL, $lines, 2);
245
246 # header finished
247- last if(length($line) == 0);
248+ last if(!defined $line or length($line) == 0);
249
250 if ($ln == 0) {
251 # response header
252@@ -221,21 +245,21 @@
253 (my $h = $1) =~ tr/[A-Z]/[a-z]/;
254
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;
260 } else {
261 $resp_hdr{$h} = $2;
262 }
263 } else {
264- diag(sprintf("unexpected line '%s'\n", $line));
265+ diag(sprintf("\nunexpected line '%s'", $line));
266 return -1;
267 }
268 }
269 }
270
271 if (not defined($resp_line)) {
272- diag(sprintf("empty response\n"));
273+ diag(sprintf("\nempty response"));
274 return -1;
275 }
276
277@@ -259,29 +283,29 @@
278 # check conditions
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));
283 return -1;
284 }
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));
288 return -1;
289 }
290 } else {
291- diag(sprintf("unexpected resp_line '%s'\n", $resp_line));
292+ diag(sprintf("\nunexpected resp_line '%s'", $resp_line));
293 return -1;
294 }
295
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));
301 return -1;
302 }
303 }
304
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));
309 return -1;
310 }
311 }
312@@ -309,12 +333,12 @@
313
314 if ($key_inverted) {
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));
318 return -1;
319 }
320 } else {
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));
324 return -1;
325 }
326 }
327@@ -322,12 +346,12 @@
328 if ($verify_value) {
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));
334 return -1;
335 }
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}));
340 return -1;
341 }
342@@ -337,7 +361,7 @@
343
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));
348 return -1;
349 }
350
351@@ -348,7 +372,7 @@
352 my ($self, $binary, $port) = @_;
353 my $child = fork();
354 if (not defined $child) {
355- diag("Couldn't fork\n");
356+ diag("\nCouldn't fork");
357 return -1;
358 }
359 if ($child == 0) {
360@@ -362,7 +386,7 @@
361 exec $binary or die($?);
362 } else {
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));
366 return -1;
367 }
368 return $child;
369Index: 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)
373@@ -17,4 +17,4 @@
374 }
375 }
376 closedir DIR;
377-runtests @fs;
378+runtests (sort @fs);
ceb30c4b
ER
379Index: configure.ac
380===================================================================
ceb30c4b
ER
381Index: SConstruct
382===================================================================
383Index: NEWS
384===================================================================
479990d7 385--- NEWS (.../tags/lighttpd-1.4.25)
cc37bbfb 386+++ NEWS (.../branches/lighttpd-1.4.x)
479990d7 387@@ -3,7 +3,10 @@
ceb30c4b
ER
388 NEWS
389 ====
390
479990d7 391-- 1.4.25 -
9a17f7bd
ER
392+- 1.4.26 -
393+ *
394+
395+- 1.4.25 - 2009-11-21
479990d7
ER
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
ceb30c4b
ER
399Index: CMakeLists.txt
400===================================================================
This page took 0.098354 seconds and 4 git commands to generate.