File argument to --cookie doesn't behave as expected #666

Closed
baumanj opened this Issue Feb 18, 2016 · 4 comments

Projects

None yet

2 participants

@baumanj
baumanj commented Feb 18, 2016

According to the man page, the file format of the file to read cookies from should be plain HTTP headers or the Netscape/Mozilla cookie file format.

I did this

Passed a file argument to --cookie of the form:

Cookie: foo=bar
Cookie: baz=qux

I expected the following

curl to send the cookie headers. I realized after reading the source that curl expects the file to contain:

Set-Cookie: foo=bar
Set-Cookie: baz=qux

It would be nice if the docs were clearer or if curl accepted either format.

curl/libcurl version

> curl -V
curl 7.29.0 (x86_64-redhat-linux-gnu) libcurl/7.29.0 NSS/3.16.2.3 Basic ECC zlib/1.2.7 libidn/1.28 libssh2/1.4.3
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp scp sftp smtp smtps telnet tftp 
Features: GSS-Negotiate IDN IPv6 Largefile NTLM NTLM_WB SSL libz 

operating system

> uname -a
Linux 3.10.0-123.20.1.el7.x86_64 #1 SMP Thu Jan 29 18:05:33 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
@jay
Member
jay commented Feb 18, 2016

I can see how that is confusing. What if we change the way it is documented to:

diff --git a/docs/curl.1 b/docs/curl.1
index beb9194..cc9f07c 100644
--- a/docs/curl.1
+++ b/docs/curl.1
@@ -216,8 +216,8 @@ read previously stored cookie lines from, which should be us
 if they match. Using this method also activates the cookie engine which will
 make curl record incoming cookies too, which may be handy if you're using this
 in combination with the \fI-L, --location\fP option. The file format of the
-file to read cookies from should be plain HTTP headers or the Netscape/Mozilla
-cookie file format.
+file to read cookies from should be plain HTTP headers (Set-Cookie style) or
+the Netscape/Mozilla cookie file format.

 The file specified with \fI-b, --cookie\fP is only used as input. No cookies
 will be written to the file. To store cookies, use the \fI-c, --cookie-jar\fP
@baumanj
baumanj commented Feb 18, 2016

That sounds good to me!

@jay jay added a commit that referenced this issue Feb 19, 2016
@jay jay curl.1: HTTP headers for --cookie must be Set-Cookie style
Bug: #666
Reported-by: baumanj@users.noreply.github.com
a11c5f3
@jay
Member
jay commented Feb 19, 2016

Thanks, landed in a11c5f3. FYI you can see the latest information for that option online: -b, --cookie.

@jay jay closed this Feb 19, 2016
@baumanj
baumanj commented Feb 19, 2016

Way to close out issue 666 with expediency! 👼

@jay jay added a commit that referenced this issue Feb 19, 2016
@jay jay CURLOPT_COOKIEFILE.3: HTTP headers must be Set-Cookie style
Bug: #666
Reported-by: baumanj@users.noreply.github.com
bdaaba5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment