node-http-proxy icon indicating copy to clipboard operation
node-http-proxy copied to clipboard

If-Modified-Since header causes parse error

Open adams-family opened this issue 2 years ago • 2 comments

The following command throws a "Parse Error: Expected HTTP/":

curl 'http://192.168.88.32:8203/' -H 'If-Modified-Since: Thu, 01 Jan 1970 00:00:00 GMT'

(Command taken from a Safari browser, removed all HTTP headers that do not contribute to the error)

The following command works:

curl 'http://192.168.88.32:8203/'

Full error message:

Error: Parse Error: Expected HTTP/
    at Socket.socketOnData (_http_client.js:515:22)
    at Socket.emit (events.js:400:28)
    at addChunk (internal/streams/readable.js:293:12)
    at readableAddChunk (internal/streams/readable.js:267:9)
    at Socket.Readable.push (internal/streams/readable.js:206:10)
    at TCP.onStreamRead (internal/stream_base_commons.js:188:23) {
  bytesParsed: 107,
  code: 'HPE_INVALID_CONSTANT',
  reason: 'Expected HTTP/',
}

Source code:

var http = httpProxy = require('http-proxy');

httpProxy.createProxyServer({ target: 'http://192.168.88.100', auth: 'user:password' })
    .listen(8203)
    .on('error', function (err, req, res) {
        console.error(err);
        res.writeHead(500, {
            'Content-Type': 'text/plain'
        });
        res.end('HTTP proxy error: ' + err);
        });

Version:

"http-proxy": "^1.18.1"

adams-family avatar Dec 26 '21 10:12 adams-family

@adams-family Hello, is this problem solved? I'm having the same problem.

whyour avatar Jan 04 '24 04:01 whyour

@whyour Unfortunately I don't really know as I'm now using this library anymore... Judging based on that there was no response to my topic, probably it hasn't got resolved.

adams-family avatar Jan 04 '24 09:01 adams-family