fukamachi / woo

A fast non-blocking HTTP server on top of libev
http://ultra.wikia.com/wiki/Woo_(kaiju)
MIT License
1.27k stars 96 forks source link

HPE_INVALID_CONSTANT error occurred in Node.js client when receive empty string #85

Closed carrotflakes closed 5 years ago

carrotflakes commented 5 years ago

Server:

(ql:quickload :clack)

(defvar *hander*
  (clack:clackup
   (lambda (env)
     (declare (ignore env))
     '(200 (:content-type "text/plain") ("")))
   :port 3000
   :server :woo))

Client in Node.js with request library:

const request = require('request');

request.get('http://localhost:3000/', (err, res, body) => console.log([err, res, body]));

Run this client then get following result:

[ { Error: Parse Error
    at Socket.socketOnData (_http_client.js:440:20)
    at emitOne (events.js:116:13)
    at Socket.emit (events.js:211:7)
    at addChunk (_stream_readable.js:263:12)
    at readableAddChunk (_stream_readable.js:250:11)
    at Socket.Readable.push (_stream_readable.js:208:10)
    at TCP.onread (net.js:594:20) bytesParsed: 115, code: 'HPE_INVALID_CONSTANT' },
  undefined,
  undefined ]

Node.js version: v10.15.0

I guess woo returns invalid response. 🤔

fukamachi commented 5 years ago

Thank you for reporting. I don’t have time to look into this now, but the error would be shown when the response length cannot be determined. I suppose Woo returns Transfer-Encoding: chunked even for empty responses.

2019年6月20日(木) 23:23 carrotflakes notifications@github.com:

Server:

(ql:quickload :clack)

(defvar hander

(clack:clackup

(lambda (env)

 (declare (ignore env))

 '(200 (:content-type "text/plain") ("")))

:port 3000

:server :woo))

Client in Node.js with request https://github.com/request/request library:

const request = require('request');

request.get('http://localhost:3000/', (err, res, body) => console.log([err, res, body]));

Run this client then get following result:

[ { Error: Parse Error

at Socket.socketOnData (_http_client.js:440:20)

at emitOne (events.js:116:13)

at Socket.emit (events.js:211:7)

at addChunk (_stream_readable.js:263:12)

at readableAddChunk (_stream_readable.js:250:11)

at Socket.Readable.push (_stream_readable.js:208:10)

at TCP.onread (net.js:594:20) bytesParsed: 115, code: 'HPE_INVALID_CONSTANT' },

undefined,

undefined ]

Node.js version: v10.15.0

I guess woo returns invalid response. 🤔

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/fukamachi/woo/issues/85?email_source=notifications&email_token=AAAWDSTQXYGTQQK6M7ENTMDP3OHE3A5CNFSM4HZTSET2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4G2XBM7Q, or mute the thread https://github.com/notifications/unsubscribe-auth/AAAWDSQBZYVOPDRFAN7YQQTP3OHE3ANCNFSM4HZTSETQ .