From 2107eb06abfb4154834e025018aa9f628e8010db Mon Sep 17 00:00:00 2001 From: Giuseppe Scrivano Date: Mon, 9 Aug 2010 12:56:49 +0200 Subject: [PATCH] Use persistent connections with proxies supporting them. --- src/ChangeLog | 4 ++++ src/http.c | 20 +++++++++++--------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 559589f7..f9e1d552 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,8 +1,12 @@ 2010-08-09 Giuseppe Scrivano + Fix a problem with HTTP/1.0 proxies. * http.c (gethttp): Specify the connection header when keep alive connections are not used. + Use persistent connections with proxies supporting them. + * http.c (gethttp): Specify Proxy-Connection to the HTTP proxy. + 2010-08-06 Giuseppe Scrivano * css-url.c (get_uri_string): Skip empty urls. diff --git a/src/http.c b/src/http.c index 7b27ae67..496e64a7 100644 --- a/src/http.c +++ b/src/http.c @@ -1573,15 +1573,9 @@ gethttp (struct url *u, struct http_stat *hs, int *dt, struct url *proxy, /* Is the server using the chunked transfer encoding? */ bool chunked_transfer_encoding = false; - /* Whether keep-alive should be inhibited. - - RFC 2068 requests that 1.0 clients not send keep-alive requests - to proxies. This is because many 1.0 proxies do not interpret - the Connection header and transfer it to the remote server, - causing it to not close the connection and leave both the proxy - and the client hanging. */ + /* Whether keep-alive should be inhibited. */ bool inhibit_keep_alive = - !opt.http_keep_alive || opt.ignore_length || proxy != NULL; + !opt.http_keep_alive || opt.ignore_length; /* Headers sent when using POST. */ wgint post_data_size = 0; @@ -1694,7 +1688,15 @@ gethttp (struct url *u, struct http_stat *hs, int *dt, struct url *proxy, if (inhibit_keep_alive) request_set_header (req, "Connection", "Close", rel_none); else - request_set_header (req, "Connection", "Keep-Alive", rel_none); + { + if (proxy == NULL) + request_set_header (req, "Connection", "Keep-Alive", rel_none); + else + { + request_set_header (req, "Connection", "Close", rel_none); + request_set_header (req, "Proxy-Connection", "Keep-Alive", rel_none); + } + } if (opt.post_data || opt.post_file_name) { -- 2.39.2