Last active
February 8, 2017 17:07
-
-
Save vicatcu/26c55f65d434c26015aa4a35f9a03ab3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// >>>> code below <<<< | |
var request = require('request'); | |
request({ | |
url: 'http://192.168.4.1', | |
body: JSON.stringify({ | |
a: "c", | |
b: "d" | |
}) | |
}, function (error, response, body) { | |
console.log("Got Response"); | |
console.log(error, response, body); | |
}); | |
// >>>> result below <<<< | |
{ Error: Parse Error | |
at Error (native) | |
at Socket.socketOnData (_http_client.js:363:20) | |
at emitOne (events.js:96:13) | |
at Socket.emit (events.js:188:7) | |
at readableAddChunk (_stream_readable.js:176:18) | |
at Socket.Readable.push (_stream_readable.js:134:10) | |
at TCP.onread (net.js:548:20) bytesParsed: 128, code: 'HPE_INVALID_HEADER_TOKEN' } undefined undefined | |
// >>>> actual tcp reply | |
/* | |
HTTP/1.1 200 OK | |
Content-Type: application/json; charset=utf-8 | |
Connection: close | |
Server: air quality egg | |
Content-Length: 41 | |
{"error":"xxxxxxxxxxxxxxxxxxxxxxxxxxxxx"} | |
*/ | |
// >>>> using curl | |
/* | |
> curl 192.168.4.1 -v -d '{"a": "c", "b": "d"}' | |
* Rebuilt URL to: 192.168.4.1/ | |
* Trying 192.168.4.1... | |
* Connected to 192.168.4.1 (192.168.4.1) port 80 (#0) | |
> POST / HTTP/1.1 | |
> Host: 192.168.4.1 | |
> User-Agent: curl/7.47.0 | |
> Accept: */* | |
> Content-Length: 20 | |
> Content-Type: application/x-www-form-urlencoded | |
> | |
* upload completely sent off: 20 out of 20 bytes | |
< HTTP/1.1 200 OK | |
< Content-Type: application/json; charset=utf-8 | |
< Connection: close | |
< Server: air quality egg | |
< Content-Length: 41 | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment