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

Handle null and undefined headers #35

Closed
75lb opened this issue Sep 23, 2021 · 4 comments
Closed

Handle null and undefined headers #35

75lb opened this issue Sep 23, 2021 · 4 comments

Comments

@75lb
Copy link

75lb commented Sep 23, 2021

Handle null and undefined header values more gracefully..

Screenshot 2021-09-23 at 13 55 18

@leoek
Copy link
Owner

leoek commented Oct 6, 2021

Thanks for reporting! Using headers with value null or undefined should indeed work like it does in the browser implementation of the fetch api.

Can you submit a PR with a testcase and the fix? Otherwise I'll try to include it in the next release myself, but I am not sure how soon that will be right now.

@DavidKrpt
Copy link

Hi, I have a related question.
Shouldn't boolean headers be supported as well ? They work in node-fetch.
Btw thanks for the package, saved me some time!

@leoek
Copy link
Owner

leoek commented Dec 22, 2021

Hi @DavidKrpt yes indeed, the goal was to replicate the request which would be executed by node-fetch or the fetch implementation of the browsers.

Therefore the expected output for fetchToCurl("https://github.com", { headers: { "x-test": null } }) should be curl 'https://github.com' -H "x-test: null" in my opinion.

Shouldn't boolean headers be supported as well ?

Good catch :) These also do not work properly right now. Since Browser just output the string true and false for booleans the same fix should be applied for them.

@leoek
Copy link
Owner

leoek commented Dec 22, 2021

just for reference: potential fix in #37

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

3 participants