File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java Micro Edition and the fly likes Chunked transfer-encoding problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Mobile » Java Micro Edition
Bookmark "Chunked transfer-encoding problem" Watch "Chunked transfer-encoding problem" New topic

Chunked transfer-encoding problem

Debashish Chakrabarty
Ranch Hand

Joined: May 14, 2002
Posts: 231

My J2ME application was recently tested and came out with a big problem on boundary conditions testing. When the client was sending less than 2048 bytes to the server it was able to handle it right. The content-length header is being set in the client and was available at the server. The client uses class to make HTTP connection to server. Here is the code snippet:

When the client data exceeds 2048 bytes I noticed from the Network Monitor tool of Wireless Toolkit that the "content-length" header was missing and another header "transfer-encoding" with value as "chunked" was being inserted. I Googled and found some discussions over this here, here and here. But none of the solutions discussed tell me how to dela with the problem on server side.

Note that when the server is sending data in chunks my J2ME client is able to handle it but not vice-versa. Infact Network Monitor tells me that as soon as data becomes even 2049 bytes the headers are sent correctly (again with no content-length and with chunked transfer-encoding) however the body is just empty. Since the body is empty my Servlet is unable to procure any request parameter and the request bombs.

Now on to the questions:
1. Why is the request body being sent as empty when data exceeds 2048 bytes? How do I make sure the data is sent in body properly?
2. Does my server need to be written differently to handle chunked request data (rather than doing request.getParameter() to read request attributes)?

SCJP2, SCWCD 1.4, PMP, ITIL Foundation
I agree. Here's the link:
subject: Chunked transfer-encoding problem
It's not a secret anymore!