Re:Online curl command line builder
by euphemize on Thursday April 23, 2015 @09:30AM
(#9426493)
Cool, gimme a field to add a custom header (e.g. "Authorization" is pretty common) and I'll use it!
[ Parent
| on HN ]
Kinda defeats the purpose of using the tool, but headers in curl are pretty simple:
curl http://example.com -H 'Authentication: root' -H 'Password: p4ssw0rd'-H is for headers; yes, but basic auth is actually the base64-encoded string of user:pass , so if constructing it manually you'd want to do something like curl -H "Authorization: Basic $(echo -n 'user:pass' |base64)" http://whatever .
Curl provides a shortcut for this as --user; e.g. curl --user name:pass http://example.com
Try it yourself with -vvv to see all the headers from both ends. Ref: http://curl.haxx.se/docs/httpscripting.html#Basic_Authentica...
http basic auth protocol: http://en.m.wikipedia.org/wiki/Basic_access_authentication
You can also use curl --negotiate -u : for kerberos (provided curl is built with it and spengo). curl supports quite a few less used auth methods, but OP mentioned custom headers, not basic auth per se, (thats why I used Authentication instead of WWW-Authenticate or Authorization as an example)