Unfortunately my code is hitting a servlet not under my control which depends on the content length being set to the actual number of bytes.

* note: the content is in an InputStream and thus its full length is not known (could be a file, pipe from someplace else [ex: with IOUtils.copy(input,output], etc..}

A POST with the java.net classes seems to send up the content length (I do not set the header at all myself) while the httpclient 4.x libs pass up -1 in. The goal is to get httpclient to do what the java.net lib does so I can use httpclient instead of java.net (it is used in all the rest of the code and having two API's makes maintenance a bit harder for some of the team).

Like it or not, that is the server that needs to be communicated with. Can httpclient be made to function as java.net does? how?

Thank you,

-------- Original Message --------
Subject: Re: HTTP Post without content-length : server failure even when
chunked
From: Oleg Kalnichevski <[email protected]>
To: HttpClient User Discussion <[email protected]>
Date: 04/27/2010 08:52 AM

On Mon, 2010-04-26 at 22:03 -0500, hanasaki wrote:
The issue seems to be that when the servlet grabs Content-Length
header, it gets -1 and the folks who wrote the servlet use that for
a new byte[Content-Length].

Oh well, what shall I say?


So with content-length = -1 httpclient will automatically use
Chunked coding?

Yes, it will


I manually set it via API anyways. With chunked=true, should the
servlet have a content length?

No, it should not

How SHOULD the servlet be determining how many bytes to read or
when to end reading?


One is expected to keep on reading until the end of data stream
(read operation returns -1).

Oleg



---------------------------------------------------------------------


To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to