Skip to content

Commit

Permalink
Adding nodejs http.request option: insecureHTTPParser (axios#2930)
Browse files Browse the repository at this point in the history
Co-authored-by: Jay <jasonsaayman@gmail.com>
  • Loading branch information
fabiel-leon and jasonsaayman committed Sep 5, 2021
1 parent eb4de25 commit 7f2cb2e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
10 changes: 9 additions & 1 deletion README.md
Expand Up @@ -456,7 +456,15 @@ These are the available config options for making requests. Only the `url` is re
// automatically. If set to `true` will also remove the 'content-encoding' header
// from the responses objects of all decompressed responses
// - Node only (XHR cannot turn off decompression)
decompress: true, // default
decompress: true // default

// `insecureHTTPParser` boolean.
// Indicates where to use an insecure HTTP parser that accepts invalid HTTP headers.
// This may allow interoperability with non-conformant HTTP implementations.
// Using the insecure parser should be avoided.
// see options https://nodejs.org/dist/latest-v12.x/docs/api/http.html#http_http_request_url_options_callback
// see also https://nodejs.org/en/blog/vulnerability/february-2020-security-releases/#strict-http-header-parsing-none
insecureHTTPParser: undefined // default

// transitional options for backward compatibility that may be removed in the newer versions
transitional: {
Expand Down
4 changes: 4 additions & 0 deletions lib/adapters/http.js
Expand Up @@ -198,6 +198,10 @@ module.exports = function httpAdapter(config) {
options.maxBodyLength = config.maxBodyLength;
}

if (config.insecureHTTPParser) {
options.insecureHTTPParser = config.insecureHTTPParser;
}

// Create the request
var req = transport.request(options, function handleResponse(res) {
if (req.aborted) return;
Expand Down

0 comments on commit 7f2cb2e

Please sign in to comment.