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

Is there a way to pass insecureHTTPParser configuration to request? #105

Closed
Overtorment opened this issue Aug 20, 2020 · 4 comments
Closed

Comments

@Overtorment
Copy link

Because of Incapsula CDN some requests are broken on latest nodejs (cli). Luckily it works ok in RN (and probably in browser).
Error that is thrown by frisbee:

FetchError {
      message: 'request to ... failed, reason: Parse Error: Invalid header value char',
      type: 'system',
      errno: 'HPE_INVALID_HEADER_TOKEN',
      code: 'HPE_INVALID_HEADER_TOKEN'
    } 

nodejs/node#27711

Workaround is to pass --insecure-http-parser to nodejs cli.

related: https://nodejs.org/api/cli.html#cli_insecure_http_parser

@niftylettuce
Copy link
Collaborator

On the server-side yes, just pass insecureHTTPParser: Boolean see https://github.com/node-fetch/node-fetch#options.

Let me know if that works for you.

@niftylettuce
Copy link
Collaborator

See previous comment. We use cross-fetch/polyfill, which then uses node-fetch, which I previously shared a link to configuration options for (which are inherited).

@Overtorment
Copy link
Author

Overtorment commented Aug 24, 2020

that did not work for me.

I tried:


this._api = new Frisbee({ baseURI: this.baseURI });

// ...


    const response = await this._api.get('/api/v1/offers?' + uri.join('&'), {
      insecureHTTPParser: true,
      headers: {
        'Access-Control-Allow-Origin': '*',
        'Content-Type': 'application/json',
      },
    });

PS. tried to pass as an option to constructor as well, no luck

@Overtorment
Copy link
Author

fyi, still no luck passing that config the way you showed, but what worked is:

NODE_OPTIONS=--insecure-http-parser=true ./node_modules/.bin/jest tests/integration/mytest.test.js

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