hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oleg Kalnichevski <ol...@apache.org>
Subject Re: utility class to create URL strings
Date Sat, 21 Jun 2008 10:40:07 GMT
On Sat, 2008-06-21 at 03:14 -0700, vbossica@scdi.org wrote:
> Quintin,
> 
> Thanks for your answer.  My answer/querstions are inlined.
> 
> > Besides the parameters added to your url "lang=" and "country=" isn't a
> > standard. That is just options used by google. There isn't even a guarentee
> > that any other sites in the world support them.
> 
> the example with google is not representative and the idea would of  
> course to be as generic as possible.  For example, the addParameter  
> method not called add<Key>Parameter(String value) but  
> addParameter(String key, String value).
> 
> one could imagine having methods for other types (addBooleanParameter,  
> addIntParameter) or add methods similar to the one found in the  
> commons-lang library (setDefautltParameter(String key, String value)  
> would only add the parameter if the value is not blank, for example).
> 
> Since this class is more of a UrlBuilder nature, java.net.URL doesn't  
> fit very well (IIRC there's an enhancement request in the Sun bug  
> database).
> 
> > Encoding is usually passed through headers,
> > and therefore is related to the request object.
> 
> I was thinking of the replacement of spaces in the query string.
> 
> > If you want to do it like you asked though, create a URL delegate class.
> > Basically just a class that manages the URL and you expose methods like the
> > ones you mentioned.
> 
> Of course this is one option.  I was just hoping that -since it's a  
> common problem- I would be able to find a common solution.
> 

Vladimir,

We have a bunch of utility methods to facilitate the process of building
and parsing of the URL queries

http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/module-client/src/main/java/org/apache/http/client/utils/URLEncodedUtils.java

Usually this class suffices for our needs 

> I can always try to write such a class using HttpCore components (e.g.  
> HttpParams) and contribute it back to the project.
> 

That would be a very welcome contribution. Please note
though ´╗┐HttpParams interface is intended to control the behavioral
aspects of HTTP components. It is not meant to represent URL query
parameters.

Cheers

Oleg  


> Regards,
> 
> -Vladimir
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org
> 


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


Mime
View raw message