Skip to content

uncaughtException when clients send non-trimmed headers #996

Closed
@randunel

Description

@randunel

None of the error handlers are triggered when proxying client requests with non-trimmed headers.

I think the request shouldn't fail at all, but it's not up to http-proxy how node.js sanitizes the outgoing requests. At least an error that can be caught should be emitted, instead of terminating the process. Alternatively, http-proxy can sanitize the headers itself (see #997).

_http_outgoing.js:339
    throw new TypeError(
    ^

TypeError: Header name must be a valid HTTP Token ["cached-id "]
    at ServerResponse.OutgoingMessage.setHeader (_http_outgoing.js:339:11)
    at /.../node_modules/http-proxy/lib/http-proxy/passes/web-o
utgoing.js:86:13
    at Array.forEach (native)
    at Array.writeHeaders (/.../node_modules/http-proxy/lib/htt
p-proxy/passes/web-outgoing.js:84:35)
    at ClientRequest.<anonymous> (/.../node_modules/http-proxy/
lib/http-proxy/passes/web-incoming.js:150:20)
    at emitOne (events.js:90:13)
    at ClientRequest.emit (events.js:182:7)
    at HTTPParser.parserOnIncomingClient [as onIncoming] (_http_client.js:469:21)
    at HTTPParser.parserOnHeadersComplete (_http_common.js:103:23)
    at Socket.socketOnData (_http_client.js:359:20)
    at emitOne (events.js:90:13)
    at Socket.emit (events.js:182:7)
    at readableAddChunk (_stream_readable.js:153:18)
    at Socket.Readable.push (_stream_readable.js:111:10)
    at TCP.onread (net.js:529:20)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions