X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/3b422ab4b2df243f48330a3329e98c9506d791c6..f7f0d6c7560a8f71707e7852a512469147aa9f84:/methods/http.cc diff --git a/methods/http.cc b/methods/http.cc index 26abc14d9..65a0cbbb7 100644 --- a/methods/http.cc +++ b/methods/http.cc @@ -402,10 +402,10 @@ ServerState::RunHeadersResult ServerState::RunHeaders() if (Debug == true) clog << Data; - for (string::const_iterator I = Data.begin(); I < Data.end(); I++) + for (string::const_iterator I = Data.begin(); I < Data.end(); ++I) { string::const_iterator J = I; - for (; J != Data.end() && *J != '\n' && *J != '\r';J++); + for (; J != Data.end() && *J != '\n' && *J != '\r'; ++J); if (HeaderLine(string(I,J)) == false) return RUN_HEADERS_PARSE_ERROR; I = J; @@ -948,9 +948,25 @@ 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) { - NextURI = Srv->Location; + 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(DeQuoteString(Srv->Location)); + return TRY_AGAIN_OR_REDIRECT; + } + else + { + NextURI = DeQuoteString(Srv->Location); return TRY_AGAIN_OR_REDIRECT; } /* else pass through for error message */ @@ -1309,7 +1325,7 @@ int HttpMethod::Loop() StopRedirects = true; else { - for (StringVectorIterator I = R.begin(); I != R.end(); I++) + for (StringVectorIterator I = R.begin(); I != R.end(); ++I) if (Queue->Uri == *I) { R[0] = "STOP";