sync-request
Advanced tools
Comparing version 4.0.2 to 4.0.3
@@ -55,3 +55,3 @@ 'use strict'; | ||
while (response !== 'pong') { | ||
const result = spawnSync('nc', ['127.0.0.1', ncPort], {input: 'ping'}); | ||
const result = spawnSync('nc', ['127.0.0.1', ncPort], {input: 'ping\r\n'}); | ||
response = result.stdout && result.stdout.toString(); | ||
@@ -76,3 +76,3 @@ } | ||
}); | ||
var res = spawnSync(command, args, {input: req}); | ||
var res = spawnSync(command, args, {input: req + '\r\n'}); | ||
if (res.status !== 0) { | ||
@@ -79,0 +79,0 @@ throw new Error(res.stderr.toString()); |
'use strict'; | ||
const net = require('net'); | ||
const concat = require('concat-stream'); | ||
const request = require('then-request'); | ||
@@ -13,4 +12,10 @@ const JSON = require('./json-buffer'); | ||
c.pipe(concat(function (stdin) { | ||
const str = stdin.toString('utf8'); | ||
let buffer = ''; | ||
c.on('data', function (data) { | ||
buffer += data.toString('utf8'); | ||
if (/\r\n/.test(buffer)) { | ||
onMessage(buffer.trim()); | ||
} | ||
}); | ||
function onMessage(str) { | ||
if (str === 'ping') { | ||
@@ -21,3 +26,3 @@ c.end('pong'); | ||
try { | ||
const req = JSON.parse(stdin.toString()); | ||
const req = JSON.parse(str); | ||
request(req.method, req.url, req.options).done(function (response) { | ||
@@ -31,5 +36,5 @@ respond({success: true, response: response}); | ||
} | ||
})); | ||
} | ||
}); | ||
server.listen(+process.argv[2]); |
{ | ||
"name": "sync-request", | ||
"version": "4.0.2", | ||
"version": "4.0.3", | ||
"description": "Make synchronous web requests", | ||
@@ -17,6 +17,6 @@ "browser": "./browser.js", | ||
"command-exists": "^1.2.2", | ||
"concat-stream": "^1.4.7", | ||
"get-port": "^2.1.0", | ||
"http-response-object": "^1.0.1", | ||
"then-request": "^2.0.1" | ||
"concat-stream": "^1.6.0", | ||
"get-port": "^3.1.0", | ||
"http-response-object": "^1.1.0", | ||
"then-request": "^2.2.0" | ||
}, | ||
@@ -23,0 +23,0 @@ "devDependencies": { |
@@ -17,7 +17,7 @@ var request = require('../'); | ||
console.dir('https://apache.org'); | ||
console.dir('https://expired.badssl.com'); | ||
var errored = false; | ||
try { | ||
// Test unauthorized HTTPS GET request | ||
var res = request('GET', 'https://apache.org'); | ||
var res = request('GET', 'https://expired.badssl.com'); | ||
console.log(res); | ||
@@ -27,3 +27,3 @@ console.log("Reponse Body: ", res.body.toString()); | ||
} catch(ex) { | ||
console.log("Successully rejected unauthorized host: https://apache.org/"); | ||
console.log("Successully rejected unauthorized host: https://expired.badssl.com"); | ||
} | ||
@@ -30,0 +30,0 @@ if (errored) { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
21969
388
+ Addedget-port@3.2.0(transitive)
- Removedget-port@2.1.0(transitive)
- Removedpinkie@2.0.4(transitive)
- Removedpinkie-promise@2.0.1(transitive)
Updatedconcat-stream@^1.6.0
Updatedget-port@^3.1.0
Updatedhttp-response-object@^1.1.0
Updatedthen-request@^2.2.0