Home

Add a comment

 

Re: Transfer-Encoding: chunked

There is a bit of misinformation here that I'd like to clear up.

"a) the server can start processing before it has everything, and b) more importantly for J2ME where memory might be a valuable resource, it lets the client send a bit of the request, free up that allocated memory and then send some more of the request."

1. "a)" is not necessarily correct as most servers will just buffer the request until it gets the whole thing THEN process it.

2. Regarding "b)", the internal behavior of the HttpConnecton class varies between devices. In many cases the output, regardless of chunking or not, will be buffered by the HttpConnection object internally which means you will essentially have to use a Socket-level StreamConnector or SecureConnector to avoid the buffering and thus running out of memory.

3. Don't forget that chunked or not the data is being broken up into packets, so it's not like non-chunked is sending the data as one huge piece. You can still do a series of writes to an OutputStream as non-chunked and (depending on the device) the memory used for that piece will be cleared before the next is sent.

4. The *real* advantage of Chunked Encoding is that you can send out a request without knowing the length of the data first. The advantages you mentioned above are incorrect, unfortunately. Remember HTTP 1.0 existed a long time before 1.1, and even back then you could sent large files from a J2ME client (depending on the device) by virtue of the fact that the data is being split into packets.

If anyone is having issues with HttpConnection it is likely because many devices don't support HTTP 1.1 and thus even if you try to set the "Transfer-Encoding" header, it will still buffer the output so it can count the bytes and insert its own "Content Length" header. If this is the case, your only option is use Sockets. I repeat, HttpConnection DOES NOT allow you to specify if you want to chunk from the client, even if you specify the appropriate headers. Just WireShark the output to prove it to yourself.

Re: Transfer-Encoding: chunked


Title
Body
HTML : b, strong, i, em, blockquote, br, p, pre, a href="", ul, ol, li, sub, sup
Name
E-mail address
Website
Remember me Yes  No 

E-mail addresses are not publicly displayed, so please only leave your e-mail address if you would like to be notified when new comments are added to this blog entry (you can opt-out later).