You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by Andre John Mas <aj...@newtradetech.com> on 2003/04/10 23:23:22 UTC

Order of methods in PostMethod

I have just spent the best part of two days trying to work out why
a servlet running int Tomcat was not getting UTF-8 when I had set my
client to send UTF-8. It turns out that if I set my PostMethod request
header after setting the request body the content does not get sent as
UTF-8.

The following gets sent as UTF-8:

       PostMethod post = new PostMethod(destinationUrl.toString());
       post.setStrictMode(false);
       post.setRequestHeader("Content-Type","text/xml; charset=UTF-8");
       post.setRequestHeader("user-agent", "myAgent");
       post.setRequestBody(content);
       post.setFollowRedirects(true);

the following doesn't:

       PostMethod post = new PostMethod(destinationUrl.toString());
       post.setStrictMode(false);
       post.setRequestBody(content);
       post.setRequestHeader("Content-Type","text/xml; charset=UTF-8");
       post.setRequestHeader("user-agent", "myAgent");
       post.setFollowRedirects(true);

reading the following web page gives no indication of this:

   http://jakarta.apache.org/commons/httpclient/charencodings.html

Is this a bug or something that is not clear in the docs.

Andre



Re: Order of methods in PostMethod

Posted by Adrian Sutton <ad...@intencha.com>.
Hi again Andre,
Probably a bit of both I'd say.  I will leave the decision on whether 
or not to change the behaviour of HttpClient to the Oleg, Mike, Jeff 
and co but will provide a patch for the documentation tonight.  Thanks 
for pointing it out.

Adrian Sutton.
On Friday, April 11, 2003, at 07:23  AM, Andre John Mas wrote:

> I have just spent the best part of two days trying to work out why
> a servlet running int Tomcat was not getting UTF-8 when I had set my
> client to send UTF-8. It turns out that if I set my PostMethod request
> header after setting the request body the content does not get sent as
> UTF-8.
> <snip>

> reading the following web page gives no indication of this:
>
>   http://jakarta.apache.org/commons/httpclient/charencodings.html
>
> Is this a bug or something that is not clear in the docs.
>
> Andre
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: 
> commons-httpclient-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: 
> commons-httpclient-dev-help@jakarta.apache.org
>


Re: Order of methods in PostMethod

Posted by Michael Becke <be...@u.washington.edu>.
Yes, it appears we have introduced an ordering dependency here.  I 
would qualify this as a bug.  One should be able to set these values in 
any order and have things work.  Andre would you add this to bugzilla? 
If we don't fix this one before beta1 it should be included in the 
release notes.

Mike

On Thursday, April 10, 2003, at 05:23 PM, Andre John Mas wrote:

> I have just spent the best part of two days trying to work out why
> a servlet running int Tomcat was not getting UTF-8 when I had set my
> client to send UTF-8. It turns out that if I set my PostMethod request
> header after setting the request body the content does not get sent as
> UTF-8.
>
> The following gets sent as UTF-8:
>
>       PostMethod post = new PostMethod(destinationUrl.toString());
>       post.setStrictMode(false);
>       post.setRequestHeader("Content-Type","text/xml; charset=UTF-8");
>       post.setRequestHeader("user-agent", "myAgent");
>       post.setRequestBody(content);
>       post.setFollowRedirects(true);
>
> the following doesn't:
>
>       PostMethod post = new PostMethod(destinationUrl.toString());
>       post.setStrictMode(false);
>       post.setRequestBody(content);
>       post.setRequestHeader("Content-Type","text/xml; charset=UTF-8");
>       post.setRequestHeader("user-agent", "myAgent");
>       post.setFollowRedirects(true);
>
> reading the following web page gives no indication of this:
>
>   http://jakarta.apache.org/commons/httpclient/charencodings.html
>
> Is this a bug or something that is not clear in the docs.
>
> Andre
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: 
> commons-httpclient-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: 
> commons-httpclient-dev-help@jakarta.apache.org
>