Skip to content

Commit

Permalink
Merge 54efc22 into ff228ee
Browse files Browse the repository at this point in the history
  • Loading branch information
willarmiros authored May 18, 2021
2 parents ff228ee + 54efc22 commit 115c731
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function RemoteRequestData(req, res, downstreamXRayEnabled) {

RemoteRequestData.prototype.init = function init(req, res, downstreamXRayEnabled) {
this.request = {
url: (req.agent && req.agent.protocol) ? (req.agent.protocol + '//' + req.getHeader('host') + stripQueryStringFromPath(req.path)) : '',
url: (req.agent && req.agent.protocol) ? (req.agent.protocol + '//' + (req.host || req.getHeader('host')) + stripQueryStringFromPath(req.path)) : '',
method: req.method || '',
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,14 @@ describe('RemoteRequestData', function() {
''
);
});
it('should use the host from the request object over headers', () => {
const requestWithHost = Object.assign(request, { host: 'different-site.com' });

assert.propertyVal(
new RemoteRequestData(requestWithHost, response, true).request,
'url',
'https://different-site.com/path/to/resource'
);
});
});
});

0 comments on commit 115c731

Please sign in to comment.