这段错误是何意思?如何解决?
java.io.IOException: malformed header field
at com.sun.midp.io.j2me.http.Protocol.readHeaders(+63)
at com.sun.midp.io.j2me.http.Protocol.sendRequestEndSession(+50)
at com.sun.midp.io.j2me.http.Protocol.sendRequest(+139)
at com.sun.midp.io.j2me.http.Protocol.getResponseMessage(+5)
at cpAppBrowser.CpNetHandler.sendMes(+84)
at testCase.TC0040_cellphone.startApp(+36)
at javax.microedition.midlet.MIDletProxy.startApp(+7)
at com.sun.midp.midlet.Scheduler.schedule(+225)
at com.sun.midp.dev.DevMIDletSuiteImpl.schedule(+7)
at com.sun.midp.Main.runLocalClass(+20)
at com.sun.midp.Main.main(+68)
我用Http连接到我写的一个Http服务器(不是Servlet)上,这是一个协议转换的东西,不能用servler,必须自己写。
我不知道是我Http服务器出的问题还是什么。可是相同的代码在不同的运行中有极少的机会正确。
我用的是Eclipse和Sun的标准模拟器。
代码如下。
public String sendMes(String message) {
String result = null;
try {
con.setRequestProperty("User-Agent", System
.getProperty("microedition.profiles"));
con.setRequestProperty("Content-Type", "MES");
con.setRequestProperty("MES", message);
con.setRequestMethod(HttpConnection.POST);
OutputStream os = con.openOutputStream();
os.flush();
os.close();
System.out.println(con.getResponseMessage());
} catch (Exception ex) {
ex.printStackTrace();
}
return result;
}