On Mon, Dec 24, 2001 at 11:44:02PM +0100,  Marc A. Lehmann  wrote:
> The problem with http://anime.plan9.de and persistency is that lftp
> closes the persistent connection for no good reason:
> 
>    ---- Connecting to anime.plan9.de (195.27.202.202) port 80
>    ---- Sending request... 
>    ---> HEAD / HTTP/1.1
>    ---> Host: anime.plan9.de
>    ---> User-Agent: lftp/2.4.8
>    ---> Accept: */*
>    ---> Referer: http://anime.plan9.de/
>    ---> Connection: keep-alive
>    ---> 
>    <--- HTTP/1.1 200 ok              
>    <--- Date: Mon, 24 Dec 2001 22:26:34 GMT
>    <--- Content-Length: 6320     
>    <--- Last-Modified: Tue, 27 Nov 2001 04:04:56 GMT
>    <--- Content-Type: text/html  
>    ---- Closing HTTP connection
> 
> "keep-alive" is not a valid token for the Connection:-header. my server
> simply ignores it (as per rfc) and creates a persistent connection (the
> default), which lftp closes. While this is not an illegal request, the
> intent was probably to create a persistent connection, which was done, so
> lftp should be fixed to take the opportunity ;)

It seems I did not read RFC well enough. The attached patch should fix it
(untested yet - I have to work over proxy).

> (sidenote: the Referer:-header above is broken, as this was the first
> request so no referer exists).

lftp simply sends current directory as Referer. It is possible to send
arbitrary string using http:referer setting.

> In general, lftp should not use HTTP/1.1 requests when it only understands
> HTTP/1.0 (my server and many others do support http/1.0-keep-alive, so
> announcing the correct protocol version magically fixes the problem, too):

It tries to understand HTTP/1.1, but it still learns ;)

The Connection header is sent for compatibility with HTTP/1.0 servers which
support keep-alive.

-- 
   Alexander.
--- Http.cc     2001/12/20 11:14:43
+++ Http.cc     2001/12/25 10:27:12
@@ -1147,6 +1146,11 @@
                  }
               }
               proto_version=(ver_major<<4)+ver_minor;
+
+              // HTTP/1.1 does keep-alive by default
+              if(proto_version>=0x11)
+                 keep_alive=true;
+
               if(!H_20X(status_code))
               {
                  if(H_CONTINUE(status_code))

Reply via email to