You are viewing a plain text version of this content. The canonical link for it is here.
Posted to httpclient-users@hc.apache.org by Matthew Hegarty <ma...@diagonal-consulting.com> on 2006/02/07 12:37:00 UTC
URL encoding problem
Hi
My problem in a nutshell is that I would like to encode a URL in exactly the
same way as InternetExplorer does - I just can't see how to do it!
In detail I have the following query:
uri = "action=query&text=%28%28MRH%29%29+&&DATABASEMATCH=Deposited_Papers
European_Materials&maxresults=1000&printfields=*/CONTENT-TYPE,*/UID&predict=
false&totalresults=true&combine=simple"
I call:
URIUtil.encodeQuery(uri, "UTF-8")
Which produces the output:
action=query&text=%2528%2528MRH%2529%2529+&&DATABASEMATCH=Deposited_Papers%2
0European_Materials&maxresults=1000&printfields=*/CONTENT-TYPE,*/UID&predict
=false&totalresults=true&combine=simple
My problem is that the '%28' characters have been re-encoded as '%2528' and
this causes the Get request to fail for my purposes.
InternetExplorer and FireFox don't do this (they only encode the space
character).
How can I get HttpClient to encode in this same way so that my query is
successful.
Thanks
Matt
Re: URL encoding problem
Posted by Roland Weber <RO...@de.ibm.com>.
Hi Matt,
>
action=query&text=%2528%2528MRH%2529%2529+&&DATABASEMATCH=Deposited_Papers%2
>
0European_Materials&maxresults=1000&printfields=*/CONTENT-TYPE,*/UID&predict
> =false&totalresults=true&combine=simple
>
>
> My problem is that the '%28' characters have been re-encoded as '%2528'
and
> this causes the Get request to fail for my purposes.
> InternetExplorer and FireFox don't do this (they only encode the space
> character).
> How can I get HttpClient to encode in this same way so that my query is
> successful.
You can't. You have to present to HttpClient a URL that is either
completely
escaped, or not at all. You can try whether the java.net.URL or
java.net.URI
classes serve your purpose. You can alse try to decode the string first,
then
re-encode it. That would prevent double encoding.
hope that helps,
Roland
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-user-help@jakarta.apache.org