| Reply | « Previous Thread | Next Thread » |
|
hello,all,
I find that HttpConnection used in 3650 may bring a problem that although the server has pushed data to here,but getLength() is zero,but in 7650,it is not zero,but a correct Integer,is it a serious problem?then how to read my data from server? thanks much. the code is here: HttpConnection connection = (HttpConnection)Connector.open(uri); connection.setRequestMethod(HttpConnection.POST); connection.setRequestProperty("User-Agent",ua); connection.setRequestProperty("Content-Language",locale); connection.setRequestProperty("Content-Length",bytes.length+" "); outputStream = connection.openOutputStream(); outputStream.write(bytes); outputStream.flush(); inputStream = connection.openInputStream(); int len = (int)connection.getLength(); //!!!!here len ==-1 in Nokia 3650! |
|
I am sorry,HttpConnection.getLeng th()==-1,not zero.
|
|
We have seen the same problem; it looks most of the header info is being stripped out. No word from Nokia yet on a solution. Here's how you can read the stream without knowing the length:
int read = 0; int offset = 0; byte tmp[] = new byte[8196]; while (true) { read = is.read(tmp, offset, 8196 - offset); if (read < 0) break; offset += read; } buf = new byte[offset]; System.arraycopy(tmp, 0, buf, 0, offset); |
| Reply | « Previous Thread | Next Thread » |
| Thread Tools | Search this Thread |
|---|---|