Hello
I found that a MIDlet will silently die on Nokia N90 and 6680 when trying to read the content of an HTTP "302 Found" server response.
Here is a small code showing it :
And here is the server-side PHP code to generate a HTTP 302 reply with content :Code:import javax.microedition.midlet.*; import javax.microedition.io.*; import java.io.*; import javax.microedition.lcdui.*; public class Test extends MIDlet { private static final String URL = "http://server.domain/your_script.php" protected void startApp() throws MIDletStateChangeException { Form f = new Form( "Test" ); String response=""; try { HttpConnection con = (HttpConnection)Connector.open( URL, Connector.READ ); InputStream in = con.openInputStream(); InputStreamReader reader = new InputStreamReader(in); char content[] = new char[1024]; int len = reader.read( content, 0, 1024 ); reader.close(); in.close(); response = String.valueOf(content,0,len); } catch( IOException e ) {} f.append( new StringItem("Reponse : ", response, StringItem.PLAIN) ); Display.getDisplay(this).setCurrent(f); } protected void pauseApp() {} protected void destroyApp(boolean arg0) throws MIDletStateChangeException{} }
It was REALLY hard to find out why my much more complicated app kept on crashing...Code:<?php header('Location: http://www.forum.nokia.com/' ); echo 'plop'; ?>
Isn't that part of the HTTP standard to send a content together with a 302 reply ?

Reply With Quote




