On Tue, 2014-03-25 at 00:03 +0000, sebb wrote:
> On 24 March 2014 23:01, Christopher BROWN <br...@reflexe.fr> wrote:
> > Hello,
> >
> > This article:
> > http://blog.lunatech.com/2009/02/03/what-every-web-developer-must-know-about-url-encoding
> >
> > ...refers to the pitfalls of using Java's standard URLEncoder / URLDecoder
> > classes for anything other than *form* encoding.  In particular, it is
> > unsuitable for path segments, and has no concept of matrix parameters (such
> > as ;jsessionid=xxx but appearing in any segment).  The standard URI class
> > in the JDK doesn't appear to provide much in the way of solutions either.
> >
> > Given that when encoding and decoding URLs/URIs, I can first split into
> > segments (easy enough splitting on "/"), does anyone on this HTTP client
> > list have any recommendations for correctly encoding and decoding each
> > individual path segment (and extracting matrix parameters)?  After
> > searching, I've found no standalone class (read: without being bloated or
> > loaded with dependencies) that can both encode and decode.  Given how many
> > implementors seem to have got it more or less wrong, I'm humble enough not
> > to try it myself unless there really is no other choice.
> 
> The java.net.URI class is worth a careful review.
> 
> It has constructors that encode parameters and a constructor that
> decodes its parameter.
> 

In addition you may want to take a look at the URIBuilder, which also
can do query parsing / formatting for you.

Oleg



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

Reply via email to