hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jacques Poulin" <jacques.pou...@gmail.com>
Subject RE: Escaping of form parameters
Date Wed, 10 Jan 2007 14:39:48 GMT
Thank you, your reply helped me a lot.

I ended up studying the PostMethod class, figured out where the post
parameters were encoded, and created a new class similar to it that didn't
encode them.  Worked instantly.

Hope that helps someone else down the road... 

-----Original Message-----
From: Roland Weber [mailto:ROLWEBER@de.ibm.com] 
Sent: 9 janvier 2007 13:57
To: HttpClient User Discussion
Subject: Re: Escaping of form parameters

Hello Jacques,

> Using HttpClient, the request fails.  Here's the log of the request :
> 
> ===== START =====
> 2007/01/09 08:43:23:640 EST [DEBUG] header - >> "POST [...]
> 2007/01/09 08:43:23:921 EST [DEBUG] header - >> "x-ajax-cap-length:
> 113|<=-[\r][\n]"
> [...]
> 2007/01/09 08:43:23:953 EST [DEBUG] header - >> "Content-Type:
> application/x-www-form-urlencoded[\r][\n]"
> 2007/01/09 08:43:23:953 EST [DEBUG] header - >> "[\r][\n]"
> 2007/01/09 08:43:23:953 EST [DEBUG] content - >> 
> "%3Clogin-request%3E%3CuserID%3Ethe user
id%3C%2FuserID%3E%3Cpassword%3Ethe
> 
password%3C%2Fpassword%3E%3Caction%3Elogin%3C%2Faction%3E%3C%2Flogin-request
> %3E%3C=-++++++"
> ===== END =====
> 
> The problem seems to be that the POST parameter name is escaped when 
> HttpClient is used.

What you are sending are not name/value pairs at all. Which means that the
Content-Type header is misleading. If that's what the server wants, so be
it. But by squeezing your data into a name/value pair, you get extra data in
the body, which will cause problems with the length part of the
x-ajax-cap-length header.

Since you're not sending name/value pairs in the default format, you should
use StringRequestEntity to define the content of the POST request:
http://jakarta.apache.org/commons/httpclient/apidocs/org/apache/commons/http
client/methods/StringRequestEntity.html
http://jakarta.apache.org/commons/httpclient/apidocs/org/apache/commons/http
client/methods/EntityEnclosingMethod.html#setRequestEntity(org.apache.common
s.httpclient.methods.RequestEntity)

Then there will be no escaping.

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


Mime
View raw message