summaryrefslogtreecommitdiff
path: root/methods/http.cc
diff options
context:
space:
mode:
authorDavid Kalnischkies <kalnischkies@gmail.com>2011-04-29 01:20:44 +0200
committerDavid Kalnischkies <kalnischkies@gmail.com>2011-04-29 01:20:44 +0200
commit4992469e453490e4c104a1b6021e48c725c499b8 (patch)
tree0a1c96a927c24591806a53a4e0caca05d61f73fd /methods/http.cc
parentc5bcc6074c1e0f9881529709a8489cccb674a3d4 (diff)
Location header in redirects should be absolute URI, but some
servers just send an absolute path so still deal with it properly
Diffstat (limited to 'methods/http.cc')
-rw-r--r--methods/http.cc18
1 files changed, 17 insertions, 1 deletions
diff --git a/methods/http.cc b/methods/http.cc
index 26abc14d9..d3e00553c 100644
--- a/methods/http.cc
+++ b/methods/http.cc
@@ -948,7 +948,23 @@ HttpMethod::DealWithHeaders(FetchResult &Res,ServerState *Srv)
&& Srv->Result != 304 // Not Modified
&& Srv->Result != 306)) // (Not part of HTTP/1.1, reserved)
{
- if (!Srv->Location.empty())
+ if (Srv->Location.empty() == true);
+ else if (Srv->Location[0] == '/' && Queue->Uri.empty() == false)
+ {
+ URI Uri = Queue->Uri;
+ if (Uri.Host.empty() == false)
+ {
+ if (Uri.Port != 0)
+ strprintf(NextURI, "http://%s:%u", Uri.Host.c_str(), Uri.Port);
+ else
+ NextURI = "http://" + Uri.Host;
+ }
+ else
+ NextURI.clear();
+ NextURI.append(Srv->Location);
+ return TRY_AGAIN_OR_REDIRECT;
+ }
+ else
{
NextURI = Srv->Location;
return TRY_AGAIN_OR_REDIRECT;