-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Added option for custom headers #887
Conversation
- Change --help option output - Accept empty header to conform to RFC 7230 (-H "empty-header" or -H "empty-header:")
}; | ||
|
||
function setHeader(str) { | ||
const m = /^(.+?)\s*(:\s*(.*))$/.exec(str); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note: not re-used, so should be safe from RegExp state caveat
if (argv.cors) { | ||
options.cors = true; | ||
if (typeof argv.cors === 'string') { | ||
options.corsHeaders = argv.cors; | ||
} | ||
} | ||
|
||
if (argv.header) { | ||
if (Array.isArray(argv.header)) { | ||
argv.header.forEach(h => setHeader(h)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note: I remember reading somewhere that forEach
actually has a performance impact over for
, but I'm considering that an unnecessary optimization and not requiring any change here.
Looks good, merging this - thanks! I've opened #899 for continued discussion before this goes into a release. |
Tests are failing. Also mentioned this in the aforementioned discussion; please respond in the discussion rather than here.
|
Difference/improvements over #885:
curl -H
andcurl --header
1Sorry :)
Relevant issues
Resolves #884
Contributor checklist
--help
outputmaster
branchMaintainer checklist
Footnotes
https://curl.se/docs/manpage.html#-H ↩