diff options
author | David Kalnischkies <kalnischkies@gmail.com> | 2013-07-26 09:22:52 +0200 |
---|---|---|
committer | David Kalnischkies <kalnischkies@gmail.com> | 2013-07-26 09:22:52 +0200 |
commit | f2380a78aa90ff8a3b76607c0c140810aff84086 (patch) | |
tree | cb270551d284b69c05948dc4a41ee953bb5bc883 /methods/http.cc | |
parent | a5b9f4890fc2b367b8f89d10ea2bdb88b8aa071a (diff) |
request absolute URIs from proxies again (0.9.9.3 regession)
Commit 2b9c9b7f28b18f6ae3e422020e8934872b06c9f3 not only removes
keep-alive, but also changes the request URI send to proxies which are
required to be absolute URIs rather than the usual absolute paths.
Closes: 717891
Diffstat (limited to 'methods/http.cc')
-rw-r--r-- | methods/http.cc | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/methods/http.cc b/methods/http.cc index 6e03e9d63..82456d78b 100644 --- a/methods/http.cc +++ b/methods/http.cc @@ -682,15 +682,27 @@ void HttpMethod::SendReq(FetchItem *Itm,CircleBuf &Out) // Just in case. if (Itm->Uri.length() >= sizeof(Buf)) abort(); - + + /* RFC 2616 ยง5.1.2 requires absolute URIs for requests to proxies, + but while its a must for all servers to accept absolute URIs, + it is assumed clients will sent an absolute path for non-proxies */ + std::string requesturi; + if (Proxy.empty() == true || Proxy.Host.empty()) + requesturi = Uri.Path; + else + requesturi = Itm->Uri; + + // The "+" is encoded as a workaround for a amazon S3 bug + // see LP bugs #1003633 and #1086997. + requesturi = QuoteString(requesturi, "+~ "); + /* Build the request. No keep-alive is included as it is the default in 1.1, can cause problems with proxies, and we are an HTTP/1.1 client anyway. C.f. https://tools.ietf.org/wg/httpbis/trac/ticket/158 */ - // see LP bugs #1003633 and #1086997. The "+" is encoded as a workaround - // for a amazon S3 bug sprintf(Buf,"GET %s HTTP/1.1\r\nHost: %s\r\n", - QuoteString(Uri.Path,"+~ ").c_str(),ProperHost.c_str()); + requesturi.c_str(),ProperHost.c_str()); + // generate a cache control header (if needed) if (_config->FindB("Acquire::http::No-Cache",false) == true) { |