Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Send HTTP-1.1 Responses. #31

Open
wants to merge 2 commits into from

4 participants

@ssmccoy
  • Despite not requiring the Host header or supporting keep-alives, send HTTP/1.1 response.
    • This will allow custom servers to actually use some HTTP/1.1 features, such as the cache-control header, even though clients are forced to delegate keep-alive behavior to their load-balancer.
    • When tested behind haproxy and friends, has no impact on upstream load-balancing.
ssmccoy added some commits
@ssmccoy ssmccoy Send HTTP/1.1 responses.
 * Despite not requiring the ``Host`` header or supporting keep-alives, send an
   HTTP/1.1 response.
   * This will allow custom servers to actually use some HTTP/1.1 features,
     such as the cache-control header, even though clients are forced to
     delagate keep-alive behavior to their load-balancer.
   * When tested behind haproxy and friends, has no impact on upstream
     load-balancing.
09bfe03
@ssmccoy ssmccoy Added META and blib to ignore 851d30c
@miyagawa
Owner

I haven't fully grokked the patch yet, but i think it should respond 1.1 only if the request in question is in 1.1.

@ssmccoy

That's certainly not required. Here's what apache does:

GET / HTTP/1.0

HTTP/1.1 200 OK
Date: Mon, 27 Aug 2012 02:50:42 GMT
Server: Apache/2.2.14 (Ubuntu) DAV/2 SVN/1.6.6 mod_python/3.3.1 Python/2.6.5
@vti
vti commented

+1

With 1.0 no chunked and friends :(

@vti
vti commented

Btw, why add Connection close? Isn't that only for 1.0?

@ssmccoy

You have to send Connection: close if you are going to close the connection. Otherwise HTTP/1.1 is keep-alive by default and you may wind up with some pipelined requests that will get dropped when you close the connection.

I didn't want to go through and implement keep-alives, because it was too much effort at this layer. In my current deployment, I push several Twiggy daemon processes to each box and have a local load balancer on the instance. The load balancer does keep-alives for me upstream.

Adding real keep alive support would be a significant change.

@vti
vti commented
@vti
vti commented
@ssmccoy
@dolmen

@vti What is the status of your fork for SockJS?

@vti

@dolmen usable under patched Feersum :) But I am doing some internal refactoring right now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Aug 13, 2012
  1. @ssmccoy

    Send HTTP/1.1 responses.

    ssmccoy authored
     * Despite not requiring the ``Host`` header or supporting keep-alives, send an
       HTTP/1.1 response.
       * This will allow custom servers to actually use some HTTP/1.1 features,
         such as the cache-control header, even though clients are forced to
         delagate keep-alive behavior to their load-balancer.
       * When tested behind haproxy and friends, has no impact on upstream
         load-balancing.
  2. @ssmccoy

    Added META and blib to ignore

    ssmccoy authored
This page is out of date. Refresh to see the latest.
Showing with 6 additions and 2 deletions.
  1. +4 −0 .gitignore
  2. +2 −2 lib/Twiggy/Server.pm
View
4 .gitignore
@@ -3,3 +3,7 @@ Makefile
inc/
pm_to_blib
*~
+.tags
+MYMETA.json
+MYMETA.yml
+blib/
View
4 lib/Twiggy/Server.pm
@@ -389,13 +389,13 @@ sub _write_headers {
sub _format_headers {
my ( $self, $status, $headers ) = @_;
- my $hdr = sprintf "HTTP/1.0 %d %s\015\012", $status, HTTP::Status::status_message($status);
+ my $hdr = sprintf "HTTP/1.1 %d %s\015\012", $status, HTTP::Status::status_message($status);
my $i = 0;
my @delim = ("\015\012", ": ");
- foreach my $str ( @$headers ) {
+ foreach my $str ( @$headers, qw( Connection close ) ) {
$hdr .= $str . $delim[++$i % 2];
}
Something went wrong with that request. Please try again.