1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Merge pull request #2986 from hardillb/get-got

Fix msg.responseUrl
This commit is contained in:
Nick O'Leary 2021-05-13 13:41:58 +01:00 committed by GitHub
commit add3dd1077
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -364,7 +364,7 @@ module.exports = function(RED) {
proxyOptions.proxy.password = proxyPassword;
}
}
//need both incase of http -> https redirec
//need both incase of http -> https redirect
opts.agent = {
http: new HttpProxyAgent(proxyOptions),
https: new HttpsProxyAgent(proxyOptions)
@ -385,13 +385,7 @@ module.exports = function(RED) {
got(url,opts).then(res => {
msg.statusCode = res.statusCode;
msg.headers = res.headers;
let hostname = res.req.host;
if (res.req.protocol === "http:" && res.socket.remotePort !== 80) {
hostname = `${hostname}:${res.socket.remotePort}`
} else if (res.req.protocol === "https:" && res.socket.remotePort !== 443) {
hostname = `${hostname}:${res.socket.remotePort}`
}
msg.responseUrl = `${res.req.protocol}//${hostname}${res.req.path}`;
msg.responseUrl = res.url;
msg.payload = res.body;
msg.redirectList = redirectList;
msg.retry = 0;