Hi, 1. Implemented an application, that does a webservice call to our servers. when the response size is around 200 Kb, iam receiving the content length as -1. It works well in Droid/ADP1/etc (receiving the original length) but fails in HTC My Touch and HTC DREAM.
2. When i replace, the content length , with 200000 , when the content length is -1. Still, cannot able to read the complete chunk from the input stream. This issue can be in other devices too. The issue could be with the buffer size/allocation ? Here is that piece of code: private byte[] doHttpRequest(String url,String req) throws IOException { InputStream is = null; HttpURLConnection c = null; OutputStream os = null; String errMsg = null; try { c = (HttpURLConnection) new URL(url) .openConnection(); c.setDoInput(true); c.setDoOutput(true); c.setConnectTimeout(15000); c.setReadTimeout(40000); c.setRequestMethod("POST"); c.setRequestProperty("Content-Language", "en-US"); os=c.getOutputStream(); os.write(("mobile_request=" + StringStuff .URLEncodeStr(req).getBytes()); rc = c.getResponseCode(); if (rc != HttpURLConnection.HTTP_OK) { throw new IllegalResponseCodeException("HTTP response code: " + rc); } is = c.getInputStream(); int len = (int) c.getContentLength(); // Length=-1 , incase of HTC DREAM/HTC Touch if (len > 0) { int actual = 0; int bytesread = 0; byte[] data = new byte[len]; while ((bytesread != len) && (actual != -1)) { actual = is.read(data, bytesread, len - bytesread); bytesread += actual; } return data; } } } -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en