hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Roland Weber <ROLWE...@de.ibm.com>
Subject Re: Escaping of form parameters
Date Tue, 09 Jan 2007 18:57:04 GMT
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/httpclient/methods/StringRequestEntity.html
http://jakarta.apache.org/commons/httpclient/apidocs/org/apache/commons/httpclient/methods/EntityEnclosingMethod.html#setRequestEntity(org.apache.commons.httpclient.methods.RequestEntity)

Then there will be no escaping.

hope that helps,
  Roland


Mime
View raw message