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 风 <30...@qq.com> on 2014/08/05 08:24:37 UTC

回复: How to send request without urlencode?

Yes, if get an HttpGet with a
string " http://xx.com/?a=<p>b</p>", a IllegalArgumentException will be
thrown.
My code is:
try {
      URL url = new URL("http://xx.com/?a=<p>b</p>‍");
      URI uri = new URI(url.getProtocol(), null, url.getHost()‍, url.getPort(), url.getPath(), url.getQuery(), null);
      HttpGet httpGet = new HttpGet(uri);
}
catch(Exception e) {
      e.printStackTrace();
}‍

‍

I have a special requirement, so need to send request without urlencode. ‍


------------------ 原始邮件 ------------------
发件人: "Qinger";<xy...@gmail.com>;
发送时间: 2014年8月5日(星期二) 下午2:13
收件人: "HttpClient User Discussion"<ht...@hc.apache.org>; 

主题: Re: How to send request without urlencode?



Does it really matter? We should urlencode the params so that the
HttpClient will execute the request normally. If you get an HttpGet with a
string " http://xx.com/?a=<p>b</p>", a IllegalArgumentException will be
thrown.
-----------------------------------------------------------------------------
为什么要不经过UrlEncode处理的请求呢。正常的程序就是应该将请求字符串UrlEncode之后,发送给服务器。


On Tue, Aug 5, 2014 at 1:16 PM, 风 <30...@qq.com> wrote:

> I want to send the request with the query without urlencode. For example:
>
>
> I want to request the url:  http://xx.com/?a=<p>b</p>
> I do want to urlencode the char: < > /
> But when i use HttpClient, it will make a request to :
> http://xx.com/?a=%3cp%3eb%3c%2fp%3e‍
>
>
> How can i send a request without urlencode? thanks very much!!

Re: 回复: How to send request without urlencode?

Posted by "Stephen J. Butler" <st...@gmail.com>.
I think that if you write your own HttpRequest subclass, and use the
client.execute(HttpHost, HttpRequest) overload, then you might get away
with what you're trying to do.

It's going to be a good amount of code copying through. Sure you can't just
fix the server to handle properly encoded URIs?


On Tue, Aug 5, 2014 at 1:24 AM, 风 <30...@qq.com> wrote:

> Yes, if get an HttpGet with a
> string " http://xx.com/?a=<p>b</p>", a IllegalArgumentException will be
> thrown.
> My code is:
> try {
>       URL url = new URL("http://xx.com/?a=<p>b</p>‍");
>       URI uri = new URI(url.getProtocol(), null, url.getHost()‍,
> url.getPort(), url.getPath(), url.getQuery(), null);
>       HttpGet httpGet = new HttpGet(uri);
> }
> catch(Exception e) {
>       e.printStackTrace();
> }‍
>
> ‍
>
> I have a special requirement, so need to send request without urlencode. ‍
>
>
> ------------------ 原始邮件 ------------------
> 发件人: "Qinger";<xy...@gmail.com>;
> 发送时间: 2014年8月5日(星期二) 下午2:13
> 收件人: "HttpClient User Discussion"<ht...@hc.apache.org>;
>
> 主题: Re: How to send request without urlencode?
>
>
>
> Does it really matter? We should urlencode the params so that the
> HttpClient will execute the request normally. If you get an HttpGet with a
> string " http://xx.com/?a=<p>b</p>", a IllegalArgumentException will be
> thrown.
>
> -----------------------------------------------------------------------------
> 为什么要不经过UrlEncode处理的请求呢。正常的程序就是应该将请求字符串UrlEncode之后,发送给服务器。
>
>
> On Tue, Aug 5, 2014 at 1:16 PM, 风 <30...@qq.com> wrote:
>
> > I want to send the request with the query without urlencode. For example:
> >
> >
> > I want to request the url:  http://xx.com/?a=<p>b</p>
> > I do want to urlencode the char: < > /
> > But when i use HttpClient, it will make a request to :
> > http://xx.com/?a=%3cp%3eb%3c%2fp%3e‍
> >
> >
> > How can i send a request without urlencode? thanks very much!!
>

Re: 回复: How to send request without urlencode?

Posted by Qinger <xy...@gmail.com>.
I'm afraid it's not possible. Also, Maybe, I have no idea how it can work.
After googling, I find the RFC_1738 that writes "

   Thus, only alphanumerics, the special characters "$-_.+!*'(),", and
   reserved characters used for their reserved purposes may be used
   unencoded within a URL."

It means that characters like '<' '>' must be urlencoded.

RFC_1738: http://www.ietf.org/rfc/rfc1738.txt



On Tue, Aug 5, 2014 at 2:24 PM, 风 <30...@qq.com> wrote:

> Yes, if get an HttpGet with a
> string " http://xx.com/?a=<p>b</p>", a IllegalArgumentException will be
> thrown.
> My code is:
> try {
>       URL url = new URL("http://xx.com/?a=<p>b</p>‍");
>       URI uri = new URI(url.getProtocol(), null, url.getHost()‍,
> url.getPort(), url.getPath(), url.getQuery(), null);
>       HttpGet httpGet = new HttpGet(uri);
> }
> catch(Exception e) {
>       e.printStackTrace();
> }‍
>
> ‍
>
> I have a special requirement, so need to send request without urlencode. ‍
>
>
> ------------------ 原始邮件 ------------------
> 发件人: "Qinger";<xy...@gmail.com>;
> 发送时间: 2014年8月5日(星期二) 下午2:13
> 收件人: "HttpClient User Discussion"<ht...@hc.apache.org>;
>
> 主题: Re: How to send request without urlencode?
>
>
>
> Does it really matter? We should urlencode the params so that the
> HttpClient will execute the request normally. If you get an HttpGet with a
> string " http://xx.com/?a=<p>b</p>", a IllegalArgumentException will be
> thrown.
>
> -----------------------------------------------------------------------------
> 为什么要不经过UrlEncode处理的请求呢。正常的程序就是应该将请求字符串UrlEncode之后,发送给服务器。
>
>
> On Tue, Aug 5, 2014 at 1:16 PM, 风 <30...@qq.com> wrote:
>
> > I want to send the request with the query without urlencode. For example:
> >
> >
> > I want to request the url:  http://xx.com/?a=<p>b</p>
> > I do want to urlencode the char: < > /
> > But when i use HttpClient, it will make a request to :
> > http://xx.com/?a=%3cp%3eb%3c%2fp%3e‍
> >
> >
> > How can i send a request without urlencode? thanks very much!!
>