cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: libcurl does not update cookie

From: Alexander Dyagilev <alervdvcw_at_gmail.com>
Date: Fri, 22 May 2015 11:01:08 +0300

On 5/22/2015 10:04 AM, Daniel Stenberg wrote:
> On Thu, 21 May 2015, Alexander Dyagilev wrote:
>
> I consider it very bad form to just refer to a site somewhere else
> when asking here on the mailing list. Ask the question here if you
> want the question here.

Yes, you're right. Sorry.

>
> Can you please show us the complete set of setopt options you use and
> explain clearly what you expect to happen and what actually happens?

I use these options:

curl_easy_setopt (m_curl, CURLOPT_WRITEFUNCTION, _WriteData);
curl_easy_setopt (m_curl, CURLOPT_WRITEDATA, this);

curl_easy_setopt (m_curl, CURLOPT_HEADERFUNCTION, _WriteHeader);
curl_easy_setopt (m_curl, CURLOPT_HEADERDATA, this);

curl_easy_setopt (m_curl, CURLOPT_FOLLOWLOCATION, TRUE);
curl_easy_setopt (m_curl, CURLOPT_MAXREDIRS, 7);

curl_easy_setopt (m_curl, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_easy_setopt (m_curl, CURLOPT_SSL_VERIFYHOST, FALSE);

curl_easy_setopt (m_curl, CURLOPT_COOKIEFILE, "");

curl_easy_setopt (m_curl, CURLOPT_URL, "...");
curl_easy_setopt (m_curl, CURLOPT_REFERER, "...");

curl_easy_setopt (m_curl, CURLOPT_USERAGENT, "");

curl_easy_setopt (m_curl, CURLOPT_HTTPHEADER, slist);

curl_easy_setopt (m_curl, CURLOPT_RESUME_FROM_LARGE, 0);

-------

"slist" contains the list of my additional headers. One of headers
contains Cookie field. Its content is:

Cookie: test_cookie_2=base_value2

My script sets cookie also. With the same name. Thus HTTP response contains:

Set-Cookie: test_cookie_2=value2

And it redirects to a new location (the same script with different GET
parameters).

I expect libcurl to replace existing cookie I specified in original
request with the new one. Thus I expect it to send this cookie:

Cookie: test_cookie_2=value2

Instead, libcurl sends both cookies:

Cookie: test_cookie_2=value2
Cookie: test_cookie_2=base_value2

Is it a bug? It seems yes according to RFC 6265 (section 5.3, par.11).
What can be done to achieve the required behavior?

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2015-05-22