Re: [squid-users] How to determine if URL in HttpRequest is an Ip address

From: Amos Jeffries <squid3_at_treenet.co.nz>
Date: Wed, 16 Oct 2013 22:31:23 +1300

Question:

On 16/10/2013 4:50 a.m., Sachin Gupta wrote:
> Is there a way to determine in squid code if the URL being accessed is
> an Ipaddress?

  You ask how to identify _whether_ the URL contained numeric IP.

Answer:

On 16/10/2013 3:48 p.m., Amos Jeffries wrote:
> You can test the request->GetHostIsNumeric() in the current releases
> to see if the host portion of the URL is an IP address.

"Use GetHostIsNumeric()" is the answer ...

On 16/10/2013 7:48 p.m., Sachin Gupta wrote:
> We are using squid 3.1.6 and every time i access a IP Based URL, i get
> 1 for GetHostIsNumeric().

... because it produces 1 whenever the URL contains a numeric IP as the
host/domain name.

http://example.com/ ---> GetHostIsNumeric() => 0 (false)

http://1.2.3.4/ ---> GetHostIsNumeric() => 1 (true)

Amos
Received on Wed Oct 16 2013 - 09:31:36 MDT

This archive was generated by hypermail 2.2.0 : Wed Oct 16 2013 - 12:00:05 MDT