×

Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    Mar 2003
    Posts
    5

    Nokia 3650,HttpConnection.getLeng th()==0,Problem?

    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!

  2. #2
    Registered User
    Join Date
    Mar 2003
    Posts
    5

    RE: Nokia 3650,HttpConnection.getLe ng th()==0,Problem?

    I am sorry,HttpConnection.getLeng th()==-1,not zero.

  3. #3
    Registered User
    Join Date
    Mar 2003
    Posts
    7
    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);

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×