You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Dylan Stamat <dy...@gmail.com> on 2005/03/08 02:06:20 UTC

[httpclient] Non-Encoded POST Request

Hello !

I'm working with a company who can't accept encoded POST's, which is
non-W3C standard, but I have to make due with this.

I've tried sub-classing the PostMethod class, and overriding the
generateRequestEntity() method with no luck.  Even when using
different Content-Type's, no luck.  Here is my implementation of the
generateRequestEntity() method (part of):

==========================
                String content = 
                    EncodingUtil.formUrlEncode(getParameters(),
                            StringPart.DEFAULT_CHARSET);
                ByteArrayRequestEntity entity = 
                    new ByteArrayRequestEntity(
                            EncodingUtil.getAsciiBytes(content), 
                            "text/plain");
==========================

Anybody have any ideas ?
Are non-encoded POST requests even supported !?

Thanks !
==
Dylan

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Re: [httpclient] Non-Encoded POST Request

Posted by Oleg Kalnichevski <ol...@apache.org>.
Dylan,

You can set any request content you want using whatever encoding you
deem appropriate simply by calling PostMethod#setRequestBody(String) or
PostMethod#setRequestBody(InputStream) methods

Hope this helps

Oleg


On Mon, 2005-03-07 at 17:06 -0800, Dylan Stamat wrote: 
> Hello !
> 
> I'm working with a company who can't accept encoded POST's, which is
> non-W3C standard, but I have to make due with this.
> 
> I've tried sub-classing the PostMethod class, and overriding the
> generateRequestEntity() method with no luck.  Even when using
> different Content-Type's, no luck.  Here is my implementation of the
> generateRequestEntity() method (part of):
> 
> ==========================
>                 String content = 
>                     EncodingUtil.formUrlEncode(getParameters(),
>                             StringPart.DEFAULT_CHARSET);
>                 ByteArrayRequestEntity entity = 
>                     new ByteArrayRequestEntity(
>                             EncodingUtil.getAsciiBytes(content), 
>                             "text/plain");
> ==========================
> 
> Anybody have any ideas ?
> Are non-encoded POST requests even supported !?
> 
> Thanks !
> ==
> Dylan
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org