I am writing a very simple HTTP client for Symbian Series 60 in an effort to upload an image to my catalina tomcat server. I am trying to avoid using HTTP 1.1 as HTTP 1.0 is less complex and therefore my HTTP response parser on the Symbian side can be simplier. I am also trying to avoid BASE64 encoding the data in an effort to conserve the limited wireless bandwidth available to me.
When I run both sides in a graphical debugger I notice the servlet dies during the while loop. I figure I am probably creating a bad HTTP POST request, but I'm not sure. Any ideas? I had no problems receiving all the content when I played with the request body by converting it to a few lines of text. (I don't remember if my response code was a happy one though.) Even now I get a partial image in the SomePhoto.jpg image on the server. Just having someone confirm that my HTTP request is correct will help me as I will then know to look elsewhere. A good example of a similar HTTP POST request would be nice too. The HTTP 1.0 spec (RFC 1945) can be found at: http://ftp.ics.uci.edu/pub/ietf/http/rfc1945.html The HTTP request coming from Symbian looks as follows: POST /ImageHandler/HandleImage HTTP/1.0 Content-Type: image/jpeg User-Agent: BitmapSender/0.10 Accept-Language: en-US Content-Length: 10489 this is 10489 bytes of binary data here...... .......... The simple servlet installed into tomcat is as follows: protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { int contentLength = request.getContentLength(); InputStream inStream = request.getInputStream(); FileOutputStream fileOutStream = new FileOutputStream("SomePhoto.jpg"); byte[] inData = new byte[100]; int totalBytesRead = 0; while(totalBytesRead < contentLength) //<--the evil servlet crash presents itself within this while loop after making a good number of loops { //I should probably mention that I used to just loop until inStream.read(inData) stopped returning data. int bytesRead = inStream.read(inData); //I got very similar behavior in that case too. fileOutStream.write(inData, 0, bytesRead); totalBytesRead += bytesRead; } inStream.close(); fileOutStream.close(); response.setContentType("text/plain"); PrintWriter writer = response.getWriter(); writer.println(http://wap.yahoo.com); } Thank you for your time and effort. Sincerely, James Carpenter Email: [EMAIL PROTECTED] AOL IM: nawkboyrules --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
