Re: Compiling libcurl for https
Date: Mon, 26 Oct 2015 03:58:49 -0400
On 10/25/2015 6:05 PM, Andrew Williams wrote:
> The console app I copied and most of the other examples I've been able
> to find for downloading files all seem to pre-define the output file
> name even when the download file name is provided as part of the URL.
> Are there any parts of libcul that allow the URL to be parsed and
> provide the requested file name to be separated from the whole URL?
> My goal is simply to download a requested file and have it land on my
> desktop with that exact same name.
> If its a process of parsing the URL on input and pulling the file name
> out as a pure string manipulation then all good.
> Just wondering if libcurl did this implicitly and I just can't find it
> in the documentation.
As Daniel said no however you can always look at the curl tool source to
see how it does a lot of things. For example in the tool is a function
get_url_file_name  that is used to parse the filename from the URL
when the -O option is specified. You may use code from the curl tool if
you abide by the license . I made an example  (or actually
co-opted one of my old examples to add get_url_file_name) that shows how
you can do it. The example, ProxyTest, uses libcurl to retrieve a file,
using a proxy if specified, and writes that file to disk with a filename
based on the filename in the URL. The example does not handle the case
where the server sets the filename.
If you want to do your own URL parsing the parser in libcurl isn't
exposed. I use joyent's http parser . You could try lifting the
parsing logic from libcurl but I recall the code paths are really
specific to the library, so I think you'd be better off with a url
List admin: http://cool.haxx.se/list/listinfo/curl-library
Received on 2015-10-26