Reputation: 31546
I can call my web service using curl like this successfully
curl -vL -c ~/.internal/cookie -b ~/.internal/cookie https://mywebservcie
this works I can see json content
Now if I open the ~/.internal/cookie file I can see 4 lines. I know that this file is in the netscape cookie file format and therefore column 6 and 7 are cookie name and content.
If now I try to call the same web service using the cookies explicitly
curl -vL -c"a=1" -c"b=2" -c"c=3" -c"d=4" https://mywebservice
I get a 401 unauthorized error.
Why does it work when I specify the whole file, but doesn't work when I specify the content of the file as individual cookies?
Upvotes: 1
Views: 414
Reputation: 5726
-c, --cookie-jar (HTTP) Specify to which file you want curl to write all cookies after a completed operation. Curl writes all cookies from its in-memory cookie storage to the given file at the end of opera- tions. If no cookies are known, no data will be written. The file will be written using the Netscape cookie file format. If you set the file name to a single dash, "-", the cookies will be written to stdout.
-c expects a file to write cookies.
-b, --cookie (HTTP) Pass the data to the HTTP server in the Cookie header. It is supposedly the data previously received from the server in a "Set-Cookie:" line. The data should be in the format "NAME1=VALUE1; NAME2=VALUE2".
Try this:
curl -vL -b "a=1; b=2; c=3; d=4" https://mywebservice
Upvotes: 1