Navigation Menu

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CURLINFO_COOKIELIST man page example: non-existing file is stdin #4930

Closed
3dyd opened this issue Feb 15, 2020 · 4 comments · Fixed by sthagen/curl-curl#85
Closed

CURLINFO_COOKIELIST man page example: non-existing file is stdin #4930

3dyd opened this issue Feb 15, 2020 · 4 comments · Fixed by sthagen/curl-curl#85

Comments

@3dyd
Copy link
Contributor

3dyd commented Feb 15, 2020

Hello,

From CURLINFO_COOKIELIST example:

/* enable the cookie engine with a non-existing file */
curl_easy_setopt(curl, CURLOPT_COOKIEFILE, "-");

But "-" stands for stdin, isn't it?

@jay
Copy link
Member

jay commented Feb 15, 2020

Thanks

@3dyd
Copy link
Contributor Author

3dyd commented Feb 15, 2020

Also could you satisfy my curiosity?

Documentation of curl_easy_getinfo says:
The data pointed-to will be filled in accordingly and can be relied upon only if the function returns CURLE_OK.

So in this part of example:

res = curl_easy_getinfo(curl, CURLINFO_COOKIELIST, &cookies);
if(!res && cookies) {
  ...
  curl_slist_free_all(cookies);
}

Why one would need to check that cookies != NULL?

If "just in case", then why not to be consistent and go further with

res = curl_easy_getinfo(curl, CURLINFO_COOKIELIST, &cookies);
if(!res && cookies) {
  ...
}
if(cookies) {
  curl_slist_free_all(cookies);
}

@jay
Copy link
Member

jay commented Feb 16, 2020

The documentation for the specific option always takes precedence, however in this case there is no conflict. If curl_easy_getinfo returns CURLE_OK then cookies was written to but is NULL if there were no cookies.

@3dyd
Copy link
Contributor Author

3dyd commented Feb 16, 2020

Perfect. Thank you.

@lock lock bot locked as resolved and limited conversation to collaborators May 20, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

Successfully merging a pull request may close this issue.

2 participants