Skip to content

Commit

Permalink
+ -- there was a bug where 304 Not Modified responses would
Browse files Browse the repository at this point in the history
+       cause a connection close (and thus RST packets) even
+       though keep-alive was negotiated and would've worked


git-svn-id: http://code.sixapart.com/svn/perlbal/trunk@439 6caf28e9-730f-0410-b62b-a31386fe13fb
  • Loading branch information
bradfitz committed Sep 14, 2005
1 parent 74b6cef commit 9012232
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
-- there was a bug where 304 Not Modified responses would
cause a connection close (and thus RST packets) even
though keep-alive was negotiated and would've worked

-- ignore URL arguments when doing directory indexing

-- work a little better under "trickle". (but still not perfect...
Expand Down
2 changes: 2 additions & 0 deletions doc/hacking/todo.txt
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,6 @@

* secure downloads, ala: http://www.lighttpd.net/documentation/secdownload.html

* fix up req_keep_alive and res_keep_alive --- too much duplicated code
and too many calls. doesn't feel right.

16 changes: 14 additions & 2 deletions lib/Perlbal/HTTPHeaders.pm
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,10 @@ sub content_length {
# given the request (self) and the backend response?" this is used in proxy
# mode to determine based on the client's request and the backend's response
# whether or not the response from the proxy (us) should do keep-alive.
#
# FIXME: this is called too often (especially with service selector),
# and should be redesigned to be simpler, and/or cached on the
# connection. there's too much duplication with res_keep_alive.
sub req_keep_alive {
my Perlbal::HTTPHeaders $self = $_[0];
my Perlbal::HTTPHeaders $res = $_[1] or Carp::confess("ASSERT: No response headers given");
Expand Down Expand Up @@ -359,6 +363,10 @@ sub res_keep_alive_options {
# answers the question: "is the backend expected to stay open?" this
# is a combination of the request we sent to it and the response they
# sent...

# FIXME: this is called too often (especially with service selector),
# and should be redesigned to be simpler, and/or cached on the
# connection. there's too much duplication with req_keep_alive.
sub res_keep_alive {
my Perlbal::HTTPHeaders $self = $_[0];
my Perlbal::HTTPHeaders $req = $_[1];
Expand All @@ -379,7 +387,11 @@ sub res_keep_alive {
$conn =~ /\bkeep-alive\b/i &&
($is_options ||
defined $self->header('Content-length') ||
$req->request_method eq 'HEAD');
$req->request_method eq 'HEAD' ||
$self->response_code == 304 || # not modified
$self->response_code == 204
); # no content

return 0;
}

Expand All @@ -404,7 +416,7 @@ sub range {
my $range = $self->header("Range");

return 200 unless
$range &&
$range &&
defined $size &&
$range =~ /^bytes=(\d*)-(\d*)$/;

Expand Down

0 comments on commit 9012232

Please sign in to comment.