mirror of https://gitee.com/bigwinds/arangodb
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:
parent
94a730edd2
commit
2c38e2a78d
|
@ -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
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue