1
0
Fork 0

make redirects relative if on the same host; later editions of the HTTP 1.1 RFC state that its valid.

this fixes #1558
This commit is contained in:
Wilfried Goesgens 2015-11-04 13:32:34 +01:00
parent 94a730edd2
commit 2c38e2a78d
2 changed files with 2 additions and 14 deletions

View File

@ -153,7 +153,7 @@ describe ArangoDB do
rescue HTTParty::RedirectionTooDeep => e
# check response code
e.response.code.should eq("301")
e.response.header['location'].should =~ /^https?:\/\/.*\/_admin\/aardvark\/index.html$/
e.response.header['location'].should =~ /^\/.*\/*_admin\/aardvark\/index.html$/
end
end

View File

@ -1752,23 +1752,11 @@ function resultUnsupported (req, res, headers) {
function handleRedirect (req, res, options, headers) {
var destination;
var url;
var url = '';
destination = options.destination;
if (destination.substr(0,5) !== "http:" && destination.substr(0,6) !== "https:") {
url = req.protocol + "://";
if (req.headers.hasOwnProperty('host')) {
url += req.headers.host;
if (req.headers.host.indexOf(':') === -1) {
// append port number if not present in "host" header
url += ":" + req.server.port;
}
}
else {
url += req.server.address + ":" + req.server.port;
}
if (options.relative) {
var u = req.url;