Skip to content

Provide a way to override HTTP parser #855

@gajus

Description

@gajus

What problem are you trying to solve?

const got = require('got');

const main = async () => {
  const response = await got('https://entradas.cinesa.es/compra/?performanceCode=185560&s=192');

  console.log(response);
};

main();

throws:

(node:52462) UnhandledPromiseRejectionWarning: RequestError: Parse Error: Invalid header value char
    at ClientRequest.<anonymous> (/Users/gajus/Documents/dev/temp/node_modules/got/source/request-as-event-emitter.js:178:14)
    at Object.onceWrapper (events.js:291:20)
    at ClientRequest.emit (events.js:208:15)
    at ClientRequest.origin.emit (/Users/gajus/Documents/dev/temp/node_modules/@szmarczak/http-timer/source/index.js:37:11)
    at TLSSocket.socketOnData (_http_client.js:456:9)
    at TLSSocket.emit (events.js:203:13)
    at addChunk (_stream_readable.js:294:12)
    at readableAddChunk (_stream_readable.js:275:11)
    at TLSSocket.Readable.push (_stream_readable.js:210:10)
    at TLSWrap.onStreamRead (internal/stream_base_commons.js:166:17)
(node:52462) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:52462) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Notes:

process.binding('http_parser').HTTPParser = require('http-parser-js').HTTPParser;

const got = require('got');

const main = async () => {
  const response = await got('https://entradas.cinesa.es/compra/?performanceCode=185560&s=192');

  console.log(response);
};

main();

It would be nice if we didn't need to override process.binding('http_parser').HTTPParser and Got accepted this as a configuration.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions