You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by Roland Weber <os...@dubioso.net> on 2007/07/21 13:17:23 UTC

[HttpCore] case sensitivity in HttpHost

Hi all,

the hostname in HttpHost is case sensitive. When using core
directly, that's not much of a problem. But HttpRoute inherits
this case sensitivity: two routes are different if the target
hostname or proxy hostname differ only in case. Since our most
important connection manager depends on routes to implement
connection re-use and to enforce connections-per-host limits,
this opens a big hole.
One way to deal with this would be to normalize the hostname
when computing a route to the host. But then
	target.equals(route.getTarget())
is false, which may lead to other problems in the application.
At least some normalization would have to be implemented by
the application itself.

The alternative I'd like to implement is the following:
- in HttpHost, store a lowercase hostname in addition to
  the mixed-case one
- in HttpHost.equals and .hashCode, use the lowercase one

What do you think?

cheers,
  Roland



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


Re: [HttpCore] case sensitivity in HttpHost

Posted by Roland Weber <os...@dubioso.net>.
>> Actually I am in favor of converting hostname to lower case the in
>> constructor in order to avoid having to create an intermediate object in
>> #hashCode.

Done. I also changed the attributes from "private" to "protected final".

cheers,
  Roland


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


Re: [HttpCore] case sensitivity in HttpHost

Posted by Roland Weber <os...@dubioso.net>.
Oleg Kalnichevski wrote:
> On Sat, 2007-07-21 at 13:23 +0200, Roland Weber wrote:
>> Forget the previous mail. The hostname is not case sensitive.
>> Comparison uses equalsIgnoreCase, hashCode calls toUpperCase.
>>
>> No need for changes at this time.
>>
> 
> Actually I am in favor of converting hostname to lower case the in
> constructor in order to avoid having to create an intermediate object in
> #hashCode. I no longer remember why I did not do that in the first
> place.

OK, I'll take care of it later.

cheers,
  Roland


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


Re: [HttpCore] case sensitivity in HttpHost

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Sat, 2007-07-21 at 13:23 +0200, Roland Weber wrote:
> Forget the previous mail. The hostname is not case sensitive.
> Comparison uses equalsIgnoreCase, hashCode calls toUpperCase.
> 
> No need for changes at this time.
> 

Actually I am in favor of converting hostname to lower case the in
constructor in order to avoid having to create an intermediate object in
#hashCode. I no longer remember why I did not do that in the first
place.

Oleg

> cheers,
>   Roland
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpcomponents-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: httpcomponents-dev-help@jakarta.apache.org
> 
> 


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


Re: [HttpCore] case sensitivity in HttpHost

Posted by Roland Weber <os...@dubioso.net>.
Forget the previous mail. The hostname is not case sensitive.
Comparison uses equalsIgnoreCase, hashCode calls toUpperCase.

No need for changes at this time.

cheers,
  Roland

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