Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RangeError: Invalid status code: 0 #1080

Closed
philios33 opened this issue Oct 23, 2016 · 3 comments
Closed

RangeError: Invalid status code: 0 #1080

philios33 opened this issue Oct 23, 2016 · 3 comments

Comments

@philios33
Copy link

Hi

I have no idea how this happens but I am getting this crash dump when I proxy some requests. It's especially annoying because I can't catch the Exception in my code as it happens in the http-proxy code.

RangeError: Invalid status code: 0
    at ServerResponse.writeHead (_http_server.js:192:11)
    at Array.writeStatusCode (/var/www/node-preview-proxy/node_modules/http-proxy/lib/http-proxy/passes/web-outgoing.js:113:11)
    at ClientRequest.<anonymous> (/var/www/node-preview-proxy/node_modules/http-proxy/lib/http-proxy/passes/web-incoming.js:157:20)
    at emitOne (events.js:96:13)
    at ClientRequest.emit (events.js:188:7)
    at HTTPParser.parserOnIncomingClient [as onIncoming] (_http_client.js:472:21)
    at HTTPParser.parserOnHeadersComplete (_http_common.js:105:23)
    at Socket.socketOnData (_http_client.js:361:20)
    at emitOne (events.js:96:13)
    at Socket.emit (events.js:188:7)

Could we add some sanity check in here? I noticed that _http_server.js does this.

statusCode |= 0;
  if (statusCode < 100 || statusCode > 999)
    throw new RangeError(`Invalid status code: ${statusCode}`);

Using version 1.15.2 of http-proxy

Thanks

@jcrugzz
Copy link
Contributor

jcrugzz commented Oct 24, 2016

@philios33 Could you inspect whats coming back from the response by logging on the proxyRes event? proxy.on('proxyRes', function (res) { console.log(res.statusCode) });

@Rob--W
Copy link

Rob--W commented Nov 8, 2017

This can easily be reproduced with the following HTTP response (e.g. via netcat):

HTTP/1.0 0
Content-Length: 0

@Rob--W
Copy link

Rob--W commented Nov 8, 2017

This is a regression, caused by stricter status validation in Node.js (nodejs/node@7e9b0dd) via nodejs/node#6291

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants