cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: curl_easy_setopt to allow for specifying the IP for connect() ?

From: Geff <boing_at_boing.com>
Date: Sun, 09 Jul 2006 16:28:34 -0700

Those are interesting points. I'll have to ponder this and the impact.

The other thing I forgot to mention was that sometimes I want to
retrieve URLs that do not have hostnames that are in DNS. I know it
sounds quirky but in certain cases I want to run some tests on QA sites
that don't necessarily have IPs in a DNS system that I can query. And
in fact I wouldn't want to allow my code to do a real DNS lookup because
if it did find an address I wouldn't want it to hit a production site.
So the desired function would be: if I don't put the DNS resolution
information in the cache, then I'd want it to fail so that I don't
affect "production". So in that case would it be possible to
hypothetically populate the DNS cache and then tell libcurl,
CURL_IPRESOLVE_CACHE_ONLY or something? So if it's not in the cache
assume the resolution fails. I'm trying to avoid writing and linking
with my own resolver if possible.

Thanks for responding so quickly.

Geff

Daniel Stenberg wrote:
> On Sun, 9 Jul 2006, Geff wrote:
>
>>> No, you need to use the address in the URL itself:
>>>
>>> curl_easy_setopt(easy, CURLOPT_URL, "http://1.2.3.4/");
>>
>> But then can I also specify the virtual host name somewhere else?
>> www.abc.com?
>
> Set a custom 'Host:' header accordingly:
>
> http://curlm.haxx.se/libcurl/c/curl_easy_setopt.html#CURLOPTHTTPHEADER
>
>> Would you be opposed to a patch to take such an option (CURLOPT_IP),
>> by using inet_pton() or something? I'm guessing this is a small patch.
>
> If this were to be added, I think I would prefer to see it as an option
> that adds an entry to the DNS cache. Like 'www.abc.def equals 1.2.3.4'.
> As otherwise we'll get trouble with how to deal with the IPs and
> resolves etc when the HTTP server responds with a redirect and other
> edge cases.
>
Received on 2006-07-10