You are viewing a plain text version of this content. The canonical link for it is here.
Posted to httpclient-users@hc.apache.org by Feng Jiang <fe...@gmail.com> on 2007/06/08 10:18:43 UTC

Can httpclient fetch a url by given ip without querying dns?

Hi all,

when i use httpclient to fetch a lot of urls, i have already had the ip of
host for each url. I don't want the httpclient to query dns for its ip,
because it will cost a lot of time. So can I explicitly set IP for each url?


Thanks a lot,

Feng

Re: Can httpclient fetch a url by given ip without querying dns?

Posted by Feng Jiang <fe...@gmail.com>.
Hi Pete,

Thanks for you answer. Well, the JVM will cache the dns information for me
automatically after the first query, but in my experience, it still cost too
many time. That is why I still need a perfect solution for it. Looks like
Oleg's solution is good.

Best regards,
Feng

On 6/8/07, Pete Keyes <PK...@starbucks.com> wrote:
>
> I assume that would work, but you shouldn't really need to do that.  I
> believe that the java.net.InetAddress class explicitly states that it
> caches DNS lookup information to avoid that cost.
>
> Look at the JavaDocs for java.net.InetAddress - it explains the
> algorithm used and how to modify it.
>
> In the end HttpClient isn't in control of the hostname-to-ip
> resolution...unless there is some kind virtual name processing being
> used.
>
> ...Pete
> Starbucks Coffee Co. - MS IT-5
> 2401 Utah Ave S
> Seattle, WA. 98134
> (w) 206-318-5933
>
> -----Original Message-----
> From: Feng Jiang [mailto:feng.a.jiang@gmail.com]
> Sent: Friday, June 08, 2007 1:19 AM
> To: httpclient-user@jakarta.apache.org
> Subject: Can httpclient fetch a url by given ip without querying dns?
>
> Hi all,
>
> when i use httpclient to fetch a lot of urls, i have already had the ip
> of
> host for each url. I don't want the httpclient to query dns for its ip,
> because it will cost a lot of time. So can I explicitly set IP for each
> url?
>
>
> Thanks a lot,
>
> Feng
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: httpclient-user-help@jakarta.apache.org
>
>

RE: Can httpclient fetch a url by given ip without querying dns?

Posted by Pete Keyes <PK...@starbucks.com>.
I assume that would work, but you shouldn't really need to do that.  I
believe that the java.net.InetAddress class explicitly states that it
caches DNS lookup information to avoid that cost.

Look at the JavaDocs for java.net.InetAddress - it explains the
algorithm used and how to modify it.

In the end HttpClient isn't in control of the hostname-to-ip
resolution...unless there is some kind virtual name processing being
used.

...Pete
Starbucks Coffee Co. - MS IT-5
2401 Utah Ave S
Seattle, WA. 98134
(w) 206-318-5933

-----Original Message-----
From: Feng Jiang [mailto:feng.a.jiang@gmail.com] 
Sent: Friday, June 08, 2007 1:19 AM
To: httpclient-user@jakarta.apache.org
Subject: Can httpclient fetch a url by given ip without querying dns?

Hi all,

when i use httpclient to fetch a lot of urls, i have already had the ip
of
host for each url. I don't want the httpclient to query dns for its ip,
because it will cost a lot of time. So can I explicitly set IP for each
url?


Thanks a lot,

Feng

---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-user-help@jakarta.apache.org


Re: Can httpclient fetch a url by given ip without querying dns?

Posted by Feng Jiang <fe...@gmail.com>.
Hi Oleg,

Thanks so much, I got it! :)

Best regards,
Feng

On 6/8/07, Oleg Kalnichevski <ol...@apache.org> wrote:
>
> On Fri, 2007-06-08 at 16:18 +0800, Feng Jiang wrote:
> > Hi all,
> >
> > when i use httpclient to fetch a lot of urls, i have already had the ip
> of
> > host for each url. I don't want the httpclient to query dns for its ip,
> > because it will cost a lot of time. So can I explicitly set IP for each
> url?
> >
> >
>
> Yes, you can. Just use IP address in the request url (or by using a
> custom HostConfiguration) and set "http.virtual-host" request parameter
> to the desired DSN name.
>
> Hope this helps
>
> Oleg
>
> > Thanks a lot,
> >
> > Feng
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: httpclient-user-help@jakarta.apache.org
>
>

Re: Can httpclient fetch a url by given ip without querying dns?

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Fri, 2007-06-08 at 16:18 +0800, Feng Jiang wrote:
> Hi all,
> 
> when i use httpclient to fetch a lot of urls, i have already had the ip of
> host for each url. I don't want the httpclient to query dns for its ip,
> because it will cost a lot of time. So can I explicitly set IP for each url?
> 
> 

Yes, you can. Just use IP address in the request url (or by using a
custom HostConfiguration) and set "http.virtual-host" request parameter
to the desired DSN name.

Hope this helps

Oleg

> Thanks a lot,
> 
> Feng


---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-user-help@jakarta.apache.org