On Mon, 2009-02-23 at 15:59 +0000, Florent Georges wrote:
> Hi,
>
> I have the following piece of code, where I create a POST
> request, based on the class StringProducer, a simple
> implementation of ContentProducer that output a string (see
> below):
>
> // the request entity
> ContentProducer prod = new StringProducer(content);
> EntityTemplate entity = new EntityTemplate(prod);
> entity.setChunked(false);
>
> // the POST method, with the above entity
> HttpPost post = new HttpPost(uri);
> post.setEntity(entity);
> client.execute(post);
>
> StringProducer is simply:
>
> private static class StringProducer
> implements ContentProducer
> {
> public StringProducer(String content) {
> myContent = content;
> }
> @Override
> public void writeTo(OutputStream out) throws IOException {
> out.write(myContent.getBytes());
> }
> private String myContent;
> }
>
> Note the following statement above:
>
> entity.setChunked(false);
>
> But in the logs, I get the following:
>
> [DEBUG] wire - >> "POST ***** HTTP/1.1[EOL]"
> [DEBUG] wire - >> "Transfer-Encoding: chunked[EOL]"
> [DEBUG] wire - >> ...
>
> Is that normal?
>
Yes, it is. This is perfectly normal. If content length of a request
entity is not known, the only way to transfer it is by using chunk
coding.
Why do not you simply use ByteArrayEntity?
Oleg
> Regards,
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]