1
http.get({host:'192.168.2.104'},function(res){
console.log("test");
.
.

Creates following error:

Error: Parse Error
at Error (native)
at Socket.socketOnData (_http_client.js:362: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:547:20)

curl response from server:

root@kali:~# curl http://192.168.2.104 -v
* Rebuilt URL to: http://192.168.2.104/
*   Trying 192.168.2.104...
* TCP_NODELAY set
* Connected to 192.168.2.104 (192.168.2.104) port 80 (#0)
> GET / HTTP/1.1
> Host: 192.168.2.104
> User-Agent: curl/7.52.1
> Accept: */*
> 
* Curl_http_done: called premature == 0
* Connection #0 to host 192.168.2.104 left intact
{"uptime":4561488,"error":0,"temp":34.30,"humidity":28.60}

Server is very simple and adds NO HEADERS to HTTP Response
Can't find a solution

Sauseee
  • 45
  • 1
  • 6
  • It would be better to show the verbose output from cURL so we might see what part of the server response is invalid. – mscdex Jun 26 '17 at 16:45
  • An HTTP response with no headers is not a valid HTTP response so cannot be parsed as an HTTP response. A status header is the minimum required. – Alex K. Jun 26 '17 at 16:48
  • status header is in but nothing else, updated curl out – Sauseee Jun 26 '17 at 16:50
  • `date:` seems to be required also: https://stackoverflow.com/questions/13483781/http-response-with-no-http-header – Alex K. Jun 26 '17 at 16:51
  • The [Node.js docs](https://nodejs.org/api/http.html#http_http_request_options_callback) say the following: "`hostname` `` Alias for host. To support url.parse(), hostname is preferred over host." Maybe give `hostname` a shot? – Brett Beatty Jun 26 '17 at 19:38

0 Answers0