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.

Re: CURLINFO_EFFECTIVE_URL when using CURLOPT_CURLU

From: Adam Light via curl-library <curl-library_at_lists.haxx.se>
Date: Tue, 7 Jun 2022 10:16:06 -0700

On Tue, Jun 7, 2022 at 8:43 AM Daniel Stenberg <daniel_at_haxx.se> wrote:

> On Tue, 7 Jun 2022, Adam Light wrote:
>
> curl_easy_getinfo() is designed to bring you information about a previous
> transfer and CURLINFO_EFFECTIVE_URL is one of those details. The
> "effective
> URL" used in the previous transfer.
>
> If you didn't do any transfer then you can't know what URL it would be!
>
> So, the fact that you actually get any content back at all before you have
> performed any transfer I call just pure luck and a circumstance that I
> consider an undocumented behavior.
>
>
The docs for curl_easy_getinfo say "The data pointed-to will be filled in
accordingly and can be relied upon only if the function returns CURLE_OK."
However if I call curl_easy_getinfo after setting the URL (with
either CURLOPT_URL or CURLOPT_CURLU) CURLE_OK is returned. So it seems that
it's not possible to determine whether the effective URL returned by
curl_easy_getinfo is actually valid.

I had been using curl_easy_getinfo as a way to determine which URL would be
used if I were to call curl_easy_perform(). If I set the URL using
CURLOPT_URL then I can use curl_easy_getinfo() to get that information.
However if I set the URL with CURLOPT_CURLU, I need to keep track of the
URL myself, which is a lot more complicated, but possible.

Thanks for your clarification
Adam


-- 
Unsubscribe: https://lists.haxx.se/listinfo/curl-library
Etiquette:   https://curl.haxx.se/mail/etiquette.html
Received on 2022-06-07