hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jacob R Quant <jacob.r.qu...@ampf.com>
Subject RE: Since URIBuilder.setQuery is deprecated shouldn't clearQuery also be deprecated?
Date Thu, 31 Oct 2013 14:14:25 GMT
> On Wed, 2013-10-30 at 18:00 +0000, Jacob R Quant wrote:
> > It seems like the preferred way to manipulate the query string associated with a
> > when using org.apache.http.client.utils.URIBuilder is using the [set|clear|add]Parameter[s]
methods rather than the setQuery and removeQuery methods. However, while the setQuery method
is deprecated the removeQuery method is not. Is this an oversight or is there a specific reason
for this? I would like to understand their intended uses better.
> >
> > (snip)
> The reason for deprecation of the #setQuery method was its inconsistency of its contract
with all other methods of the class. #setQuery expected input to be URL encoded whereas all
other methods expect unescaped input. The choice was between changing the contract of the
method and by doing so breaking pretty much every single application reliant on URIBuilder
or method deprecation in favor of another method with slightly less intuitive name. So, one
should be using [set|clear| add]Parameter[s] methods to work with query parameters and the
#setCustomQueury method to set custom queries.
> Hope this helps
> Oleg


Thank you for that explanation. The point about the URL encoding makes perfect sense. So if
I understand correctly #setCustomQuery is the replacement for #setQuery. As for the clearing
operation, one could use #clearQuery in both cases (parameters or custom query), but there
is also a #clearParameters method for naming consistency. Please let me know if that is incorrect.

****************************************************************************** "This message
and any attachments are solely for the intended recipient and may contain confidential or
privileged information. If you are not the intended recipient, any disclosure, copying, use,
or distribution of the information included in this message and any attachments is prohibited.
If you have received this communication in error, please notify us by reply e-mail and immediately
and permanently delete this message and any attachments. Thank you." ******************************************************************************

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

View raw message