diff options
| author | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2012-01-11 02:17:38 +0900 |
|---|---|---|
| committer | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2012-01-11 02:17:38 +0900 |
| commit | a6803c21b554e204ca48d12d44d274391ce33252 (patch) | |
| tree | c7f4a7c8d447c3f59d909db0297ca8dceb0b65df /src/Request.cc | |
| parent | 2997fa0631ef85723b14691b5bca177538c76785 (diff) | |
Support network-path reference in HTTP redirect.
Diffstat (limited to 'src/Request.cc')
| -rw-r--r-- | src/Request.cc | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/Request.cc b/src/Request.cc index dfdfff19..82f7f4e7 100644 --- a/src/Request.cc +++ b/src/Request.cc @@ -108,9 +108,16 @@ bool Request::redirectUri(const std::string& uri) { return false; } std::string redirectedUri; - if(uri.find("://") == std::string::npos) { + if(util::startsWith(uri, "//")) { + // Network-path reference (according to RFC 3986, Section 4.2) + // Just complement current protocol. + redirectedUri = getProtocol(); + redirectedUri += ":"; + redirectedUri += uri; + } else if(uri.find("://") == std::string::npos) { // rfc2616 requires absolute URI should be provided by Location header // field, but some servers don't obey this rule. + // UPDATE: draft-ietf-httpbis-p2-semantics-18 now allows this. uri::UriStruct rus(us_); rus.query.clear(); rus.file.clear(); |
