curl / Mailing Lists / curl-library / Single Mail
Buy commercial curl support from WolfSSL. We help you work out your issues, debug your libcurl applications, use the API, port to new platforms, add new features and more. With a team lead by the curl founder himself.

sharing cookies … bug?

From: Felipe Gasper via curl-library <curl-library_at_cool.haxx.se>
Date: Thu, 5 Mar 2020 10:10:16 -0500

I’ve got the following sample code:

=====
#include <stdio.h>
#include <curl/curl.h>

#define SHARE_SETOPT(easy, value) curl_easy_setopt(easy, CURLOPT_SHARE, value)

int main() {
    fprintf(stderr, "Cookie version - %s\n", curl_version());

    CURLSH* share = curl_share_init();
    curl_share_setopt(share, CURLSHOPT_SHARE, CURL_LOCK_DATA_COOKIE);

    CURL* easy1 = curl_easy_init();
    curl_easy_setopt( easy1, CURLOPT_VERBOSE, 1 );
    SHARE_SETOPT( easy1, share );

    curl_easy_setopt(easy1, CURLOPT_COOKIEFILE, "");

    curl_easy_setopt( easy1, CURLOPT_URL, "http://www.google.com/search?q=perl" );
    curl_easy_perform(easy1);

    CURL* easy2 = curl_easy_init();
    curl_easy_setopt( easy2, CURLOPT_VERBOSE, 1 );
    SHARE_SETOPT( easy2, share );

    curl_easy_setopt( easy2, CURLOPT_URL, "http://www.google.com/search?q=curl" );
    curl_easy_perform(easy2);

    return 0;
}
=====

… which I compile with this statement:

gcc -L/Users/felipe/mycurl/lib -I/Users/felipe/code/curl/include/curl -o curl_google curl_google.c -lcurl && ./curl_google 2>&1 | grep Cookie | grep -v Set-Cookie

… and get:

Cookie version - libcurl/7.69.0-DEV OpenSSL/1.1.1d zlib/1.2.11 libidn2/2.3.0 libpsl/0.21.0 (+libidn2/2.1.1)

Note that there’s no “Cookie:” header being sent.

Am I “holding it wrong”, or is this a bug? I see the same behavior in 7.68, but if I compile against an older libcurl, I get what I expect:

Cookie version - libcurl/7.54.0 LibreSSL/2.6.5 zlib/1.2.11 nghttp2/1.24.1
Cookie: CGIC=IgMqLyo; NID=199=K3m9Ak7ESVyswq45PmirFnDu74CgtqWd-vbDWY2FTfA4JySBSGXzv0QL84nZpOVMmpUZ26y-1C3Sdi03-TMo3t1YghWTeALjbHllRX6LgZiilNOVUtLAezy_fLXAscQ4JOZvO34yGmvTPfNB18My4g-Wn2MYUnL2Fo6VoTQhjYA

This is all under macOS.

Thank you!

-FG
-------------------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette: https://curl.haxx.se/mail/etiquette.html
Received on 2020-03-05