Skip to content

Commit 4cdd460

Browse files
committed
hotfix remapHosts
1 parent 7294e3f commit 4cdd460

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -364,10 +364,10 @@ Full API
364364
* CALLBACK(ERROR) function
365365
1. ERROR string if there was an error
366366

367-
**remapHosts(PORT, '{"example.com": "1.2.3.4"}', CALLBACK)**
367+
**remapHosts(PORT, {'example.com': '1.2.3.4'}, CALLBACK)**
368368

369369
Overrides normal DNS lookups and remaps the given hosts with the associated IP address
370-
Payload data should be json encoded set of name/value pairs (ex: {"example.com": "1.2.3.4"})
370+
Payload data should be json encoded set of name/value pairs (ex: {'example.com': '1.2.3.4'})
371371

372372
PARAMETERS:
373373

index.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,16 @@ Proxy.prototype = {
195195
this.doReqWithOptions(options, postData, cb);
196196
},
197197

198+
remapHosts: function (port, hostsToAdd, cb) {
199+
var postData = JSON.stringify(hostsToAdd);
200+
var options = {
201+
host: this.host, port: this.port, method: 'POST', path: '/proxy/' + port + '/hosts', headers: {
202+
'Content-Type': 'application/json'
203+
}
204+
};
205+
this.doReqWithOptions(options, postData, cb);
206+
},
207+
198208
doReq: function (method, url, postData, cb) {
199209
var options = {
200210
host: this.host, port: this.port, method: method, path: url, headers: {
@@ -227,11 +237,8 @@ Proxy.prototype = {
227237
req.write(postData);
228238
}
229239
req.end();
230-
},
231-
232-
remapHosts: function (port, postData, cb) {
233-
this.doReq('POST', '/proxy/' + port + '/hosts', postData, cb)
234240
}
241+
235242
};
236243

237244
module.exports = {

0 commit comments

Comments
 (0)