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.

How to use libcurl to get the final URL of a site after a redirection ?

From: Morbius via curl-library <curl-library_at_cool.haxx.se>
Date: Sun, 19 Jul 2020 11:35:00 +0700

I am a beginner at libcurl.

I have installed curl 7.72.0-DEV (x86_64-pc-win32) libcurl/7.72.0-DEV
Schannel WinIDN. I work with MinGW C/C++ on Windows 7 and Windows 10.

What I wish to do.

I would like to write a function to obtain the final URL from a site which
redirects to another site using libcurl functions. I need some guidance on
this.

Example.

The site "http://site.com" redirects to
"https://www.salesforce.com/products/platform/overview".

So, I would like my function to return the final URL as an output when given
the initial URL as an input. I do not need the whole body of the redirected
page. Only the new URL.

What I have done so far.

Gone through the libcurl documentation and tried some of the examples given.

For instance, getredirect.c
(https://curl.haxx.se/libcurl/c/getredirect.html)

However, I didn't get the desired result.

My apologies if my question is trivial or has already been answered. The
curl-library seems huge !

Could someone help ?

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