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

"Parse Error: Invalid header value char” on some requests #155

Open
dickorydock opened this issue Mar 11, 2021 · 0 comments
Open

"Parse Error: Invalid header value char” on some requests #155

dickorydock opened this issue Mar 11, 2021 · 0 comments

Comments

@dickorydock
Copy link

dickorydock commented Mar 11, 2021

I'm getting this error on some follow-redirects calls. It's working fine on others, no problem. I'm not sure what and don't know what other information I could provide that might be helpful here, but wanted to mention it. Here is how I am calling it:


const { http, https } = require('follow-redirects').wrap({
  http: require('http'),
  https: require('https'),
  mailto: {
    request: (options, callback) => {
      setImmediate(callback, options, { mailto: options, headers: {} });
      return new class extends EventEmitter { end() {} };
    }
  },
});
 const request = http.request(requestOptions, response => { 
                    newURL = response.responseUrl;
                    resolve(response.responseUrl)

And here is the error:

events.js:292
throw er; // Unhandled 'error' event
^
Error: Parse Error: Invalid header value char
at TLSSocket.socketOnData (_http_client.js:509:22)
at TLSSocket.emit (events.js:315:20)
at addChunk (internal/streams/readable.js:309:12)
at readableAddChunk (internal/streams/readable.js:284:9)
at TLSSocket.Readable.push (internal/streams/readable.js:223:10)
at TLSWrap.onStreamRead (internal/stream_base_commons.js:188:23)
Emitted 'error' event on Writable instance at:
at ClientRequest.eventHandlers.<computed> (/app/node_modules/follow-redirects/index.js:13:24)
at ClientRequest.emit (events.js:315:20)
at TLSSocket.socketOnData (_http_client.js:516:9)
at TLSSocket.emit (events.js:315:20)
[... lines matching original stack trace ...]
at TLSWrap.onStreamRead (internal/stream_base_commons.js:188:23) {
bytesParsed: 633,
code: 'HPE_INVALID_HEADER_TOKEN',
reason: 'Invalid header value char',
rawPacket: Buffer(869) [Uint8Array] [
117, 114, 101,  ... 769 more items]
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

2 participants
@dickorydock and others