Solved

content-length in http , depends on what ?

Posted on 2004-10-25
186 Views
Last Modified: 2010-07-27

I have a mobile application that downloads some data from web-server database , it was working fine with the mobile 6610 before from same place, but now it is not working properly !,
 
- What happenned is, when I get the data using the php code resides in my server it was not returning the "length" of the packet , but now it is returning the length ( using http.getLength() method in java, normally was returing -1 , but now returning 93 for some strange reason !!! )  can yopu help me please what could be happenning ?!, returning or not returning the packet length depends on what ?

- Also I tried to handle the data reception when length is available, but something is still wrong
herein the code
      if( len != -1) {      debug="6";
             for(int i =0 ; i < len ; i++ ){
                   ch = iStrm.read();
                   bStrm.write(ch);      debug="7"; //it stops here !
              if (ch == 10) { // incase length is available, no detection of ch==10 or 13
                        vStr.addElement(bStrm.toString());
                                  bStrm.reset();
                       }
      }
      }
            else
            while ( (ch = iStrm.read()) != -1) {
                    bStrm.write(ch);
                  if (ch == 10) {
                    vStr.addElement(bStrm.toString());
                    bStrm.reset();
            }
      } // while


- one important point is why the length always returning 93 even if the data is more , I know in http it comes in chunks , but not chunks of 93 bytes !


thanks very much for your help !
0
Question by:khamouda
    12 Comments
     
    LVL 13

    Expert Comment

    by:petmagdy
    please i don't understand, what changed in the application to become not working, the device or the Web components?
    0
     
    LVL 1

    Author Comment

    by:khamouda

    I am not sure actually, I even posted a question to my web hosting company if they have changed any thing !. Actually the application is working fine with some mobiles ( latest mobiles ) but with nokia 6610 & 6220 it was working fine , but now it is not !!!, in 6220 I got an exception :missing CRLF  ( I think it means carriage return line feed ) , this is why I tried to change the line if ( ch == 10 ) to ch== 13 or both , but still some thing has been changed in the received data format

    thanks
    0
     
    LVL 13

    Accepted Solution

    by:
    ok take care that 6610 and 6220 is series 30 or 40 they are limited to 64 K RAM only!! so probably if the return HTML is very long it will not work, concentrate on Series 60 mobiles like 3650, 3660
    0
     
    LVL 1

    Author Comment

    by:khamouda
    can you comment on this :

    but now it is returning the length ( using http.getLength() method in java, normally was returing -1 , but now returning 93 for some strange reason !!! )  can yopu help me please what could be happenning ?!, returning or not returning the packet length depends on what ?
    0
     
    LVL 13

    Expert Comment

    by:petmagdy
    one more question r u using MIDP 1.0 or 2.0?
    0
     
    LVL 13

    Expert Comment

    by:petmagdy
    try to search for ur problem at:

    http://www.forum.nokia.com/main.html

    specify in ur search the nokia model has the problem
    0
     
    LVL 86

    Expert Comment

    by:CEHJ
    A client application should not rely on the content length being provided. It should simply read until EOF
    0
     
    LVL 1

    Author Comment

    by:khamouda

    the problem actually with the midp1. Reading until the EOF ( -1 )  could not finish if the length is indicated, I read it somewhere

    0
     
    LVL 86

    Expert Comment

    by:CEHJ
    >>could not finish if the length is indicated

    I find that hard to believe. I don't normally deal with J2ME. Can you post a link to the API docs?
    0
     
    LVL 13

    Expert Comment

    by:petmagdy
    khamouda
    This is a device specific problem u need to return to the manifacturer site to see if this problem is reported and what to do about it, if it is not fixed concentrate on the devices that works.

    I saw even worth cases while I was developing J2ME products different devices and vendors and series and models is a big miss u must focus on the reliable devices for ur application and the devices u r mentioning that has the problem is not suitable for applications that deal with networks it is only 64 K RAM
    0
     
    LVL 13

    Expert Comment

    by:petmagdy
    Hi Venabili

    My advice was quite correct, because I worked on J2ME devices before and I know (and faced actually) that the mentioned problem can be device specific, means specific for the mobile model used
    0
     
    LVL 1

    Author Comment

    by:khamouda

    please magdy can u help in this question http://www.experts-exchange.com/Programming/Wireless_Programming/Q_21199559.html

    is their any WAP APto be used in J2ME ,  I I think it is a good idea to write one !

    khaled
    0

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Product Review - Android Remix

    Come along for the ride with our Senior Product Manager, Brian Matis, as he reviews the Android Remix.

    Suggested Solutions

    1. Package the applet into a JAR file. The applet must be in a JAR file before a certificate can be attached to it. Use the jar JDK utility. If the applet was previously referenced with the help of a codebase attribute in  tag, replace the codebase …
    Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
    Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
    Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:

    884 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now