@bbc/http-transport
Advanced tools
Comparing version 3.5.3 to 3.5.4
@@ -7,2 +7,3 @@ 'use strict'; | ||
const Request = require('request'); | ||
const dns = require('dns'); | ||
@@ -29,5 +30,12 @@ const REQUIRED_PROPERTIES = [ | ||
const req = ctx.req; | ||
const opts = Object.assign({ | ||
time: true | ||
time: true, | ||
agentOptions: { | ||
lookup: function(domain, options, cb) { | ||
// Prevent Node from reordering A and AAAA records. | ||
// See https://nodejs.org/api/dns.html#dns_dns_lookup_hostname_options_callback | ||
options.verbatim = true; | ||
return dns.lookup(domain, options, cb); | ||
} | ||
} | ||
}, ctx.opts); | ||
@@ -63,3 +71,2 @@ | ||
const method = ctx.req.getMethod(); | ||
return this._request[toAsyncMethod(method)](url, opts); | ||
@@ -66,0 +73,0 @@ } |
{ | ||
"name": "@bbc/http-transport", | ||
"version": "3.5.3", | ||
"version": "3.5.4", | ||
"description": "A flexible, modular REST client built for ease-of-use and resilience.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -8,2 +8,3 @@ 'use strict'; | ||
const sandbox = sinon.sandbox.create(); | ||
const dns = require('dns'); | ||
@@ -255,3 +256,21 @@ const RequestTransport = require('../../lib/transport/request'); | ||
}); | ||
it('enables uses verbatim', () => { | ||
nock.cleanAll(); | ||
api.get('/').reply(200, simpleResponseBody); | ||
sinon.spy(dns, 'lookup'); | ||
const ctx = createContext(url); | ||
return new RequestTransport() | ||
.execute(ctx) | ||
.then((ctx) => { | ||
ctx.res.httpResponse.request.agentOptions.lookup('www.example.com', {}, () => {}); | ||
sinon.assert.calledWith(dns.lookup, 'www.example.com', {verbatim: true}); | ||
}) | ||
.catch(assert.ifError); | ||
}); | ||
}); | ||
}); |
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
387452
6970
2