hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hanasaki jiji <hanas...@gmail.com>
Subject HTTP Post without content-length : server failure even when chunked
Date Mon, 26 Apr 2010 20:22:17 GMT
Using httpclient 4.0.1 and doing an http POST
NOTE: this has been tried with both "chunked = true" and false

The POST code does the following:
            InputStreamEntity uploadHttpEntity =
                    new InputStreamEntity(sourceInputStream, -1);
            uploadHttpEntity.setChunked(true);
            httppost.setEntity(uploadHttpEntity);

Where the InputStream is of an unknown source.  It could be the result
of ByteArrayInputStream, from a file or any other class that resolves
to an "InputStream".  Thus, the "-1" in the InputStreamEntity and the
use of this class vs perhaps a StringEntity.

The server code explicitly looks for the Content-Length header which
is seen as -1 and thus fails thinking that the length is either -1 or
it already has an EOF.  Interestingly a POST with
java.net....HTTPURLConnection works fine.

How can HTTPClient be used and have it send up the length as the
java.net classes do?

Thank you,

---------------------------------------------------------------------
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