hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefan Magnus Landrø <stefan.lan...@gmail.com>
Subject Re: 400 bad request POSTing to Tomcat 7.0.42
Date Wed, 25 Feb 2015 18:28:57 GMT
Few questions:

Why not use a more appropriate entity type? ByteArrayEntity? StreamEntity?

How do you consume the response?





Sendt fra min iPhone

> Den 25. feb. 2015 kl. 17.26 skrev Alessandro Manzoni <manzoni.alessandro4@gmail.com>:
> 
> I made a simple client that sends a xml stream to a webapp running on tomcat 7 by POST
method.
> Both client and tomcat run on the same server (linux). HTTPClient version is 4.2.2.
> 
> The xml stream is formally correct. Somtimes, when the stream is more than 30KB tomcat
replies with an html page reporting 400 bad request. When the stream is smaller goes fine.
> 
> This is my code:
>            HttpClient httpclient = new DefaultHttpClient();
>            HttpPost httppost = new HttpPost(uri);
>            StringEntity entity = new StringEntity(new String(output.toByteArray()), ContentType.TEXT_XML);
>            httppost.setEntity(entity);
>            return httpclient.execute(httppost);
> 
> where:
> - uri is the uri of the webapp, always the same.
> - output is a ByteArrayOutputStream that contains the xml stream
> 
> Should I put some more headers? Or change somewhat to avoid the error?
> 
> Thanks, regards.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org


Mime
View raw message