commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject Re: problem in sending the correct http request
Date Tue, 01 Jun 2004 14:27:21 GMT

Per default HTTP POST uses so called URL-encoding to encode the request body.
To override the default behaviour use PostMethod#setRequestBody(String)

  "XMLMSG=<A1> <B1> abc </B1> <B1> bd</B1> <B2> 1 </B2>
httppost.setRequestHeader("Content-type", "TEXT/PLAIN");

Hope this helps


>-- Original Message --
>Reply-To: "Jakarta Commons Users List" <>
>From: "Ravi Mutyala" <>
>To: "Jakarta Commons Users List" <>
>Subject: Re: problem in sending the correct http request
>Date: Tue, 01 Jun 2004 14:03:44 GMT
>Changing request header to
>httppost.setRequestHeader("Content-type", "TEXT/PLAIN");  
>hasn't helped.
>I printed the request that I sent with the namevaluepair using
>        String temp =  httppost.getRequestBodyAsString();
>        System.out.println( "Request  Object now is"+ temp);
>I got the requestbody is something below
>what can be the reason for this kind of ouput when i'm expecting
><A1> <B1> abc </B1> <B1> bd</B1> <B2> 1 </B2>
</A1> ?
>Is this the way how the POSTed data is sent across? I checked
>out the POST data using an IE plugin and the HTML that is
>working has
>a name value pair XMLMSG and <A1> <B1> abc </B1> <B1> bd</B1>
><B2> 1 </B2> </A1>.
>thanks in advance.
>Oleg Kalnichevski writes:
>> Ravi,
>> If you are lucky setting content type to TEXT/PLAIN
>> httppost.setRequestHeader("Content-type", "TEXT/PLAIN");
>> instead of
>> httppost.setRequestHeader("Content-type", "text/xml;
>> charset=ISO-8859-1");
>> may do the trick. If you are unlucky, the one sure way to know would be
>> to get hold of the complete HTTP request sent by the browser. There are
>> several possibilities to do so: (1) use a proxy capable of HTTPS
>> proxying (not just tunneling) (2) use a browser plugin that can display
>> request/response headers for a particular HTTP session
>> In order to see what exactly HttpClient sends across the wire you way
>> want to activate the wire log
>> Oleg
>15 Mbytes Free Web-based and  POP3
>Sign up now:
>To unsubscribe, e-mail:
>For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message