JAX-RS: escaping UriBuilder query params

  • From: "Manger, James H" <James.H.Manger@...>
  • To: "users@..." <users@...>
  • Subject: JAX-RS: escaping UriBuilder query params
  • Date: Wed, 23 Jul 2008 13:04:42 +1000
  • Accept-language: en-US, en-AU
  • Acceptlanguage: en-US, en-AU
  • Mailing-list: contact users-help@...; run by ezmlm

I suggest renaming
  UriBuilder replaceQueryParams(String query);
to
  UriBuilder replaceQuery(String query);
or (better still) to
  UriBuilder query(String query);
 
 
It seems trivial but it is sort of important as query parameters need different %-escaping than a whole query.
 
queryParam(String name, Object… values) should %-escape ‘=’ and ‘&’ in the name, and ‘&’ in the values (and similarly for any referenced placeholder variable values). replaceQueryParam(String, Object…) should behave the same.
 
replaceQueryParams(String), however, should not %-escape ‘=’ or ‘&” in its argument or (it follows) in placeholder variable values it references.
 
For instance,
 
  UriBuilder.fromPath(“search”).replaceQueryParam(“q”, “{term}”).build(“Jack&Jill=water”)
  -> “search?q=Jack%26Jill%3Dwater”
 
  UriBuilder.fromPath(“search”).replaceQueryParams(“q={term}”).build(“Jack&Jill=water”)
  -> “search?q=Jack&Jill=water”
 
Removing “Params” from the latter gives some hint that it is not equivalent to the former, in that it will not be careful to preserve any parameter structure.
 
  UriBuilder.fromPath(“search”).query(“q={term}”).build(“Jack&Jill=water”)
  -> “search?q=Jack&Jill=water”
 
James Manger
 


JAX-RS: escaping UriBuilder query params

Manger, James H 07/23/2008

Re: JAX-RS: escaping UriBuilder query params

Marc Hadley 07/23/2008

Re: JAX-RS: escaping UriBuilder query params

Stephan Koops 07/23/2008
Terms of Use; Privacy Policy; Copyright ©2013-2016 (revision 20160708.bf2ac18)
 
 
Close
loading
Please Confirm
Close