Skip to content

Commit

Permalink
replace request with needle
Browse files Browse the repository at this point in the history
  • Loading branch information
garrylachman committed Jul 11, 2017
1 parent 48f6215 commit 117078f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
15 changes: 7 additions & 8 deletions lib/nat-upnp/device.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const nat = require('../nat-upnp')
const request = require('request');
const needle = require('needle');
const url = require('url');
const fastXmlParser = require('fast-xml-parser');
const {Buffer} = require('buffer');
Expand All @@ -24,7 +24,7 @@ module.exports = class Device {
callback(err, body);
}

request(url, (err, res, body) => {
needle.get(url, (err, res, body) => {
if (err) return callback(err);

if (res.statusCode !== 200) {
Expand Down Expand Up @@ -123,17 +123,16 @@ module.exports = class Device {
'</s:Body>' +
'</s:Envelope>';

request({
method: 'POST',
url: info.controlURL,
const needleOptions = {
headers: {
'Content-Type': 'text/xml; charset="utf-8"',
'Content-Length': Buffer.byteLength(body),
'Connection': 'close',
'SOAPAction': JSON.stringify(info.service + '#' + action)
},
body: body
}, (err, res, body) => {
}
};

needle.post(info.controlURL, body, needleOptions, (err, res, body) => {
if (err) return callback(err);

if (res.statusCode !== 200) {
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nat-upnp-2",
"version": "3.0.1",
"version": "3.0.2",
"main": "lib/nat-upnp",
"author": "Garry Lachman <garry@lachman.co>, Fedor Indutny <fedor@indutny.com>",
"homepage": "https://github.com/garrylachman/node-nat-upnp-2",
Expand All @@ -19,6 +19,6 @@
"async": "^2.5.0",
"fast-xml-parser": "^2.5.1",
"ip": "^1.1.5",
"request": "^2.81.0"
"needle": "^1.6.0"
}
}

0 comments on commit 117078f

Please # to comment.