<iframe align="center" marginwidth="0" marginheight="0" src="http://www.zealware.com/csdnblog336280.html" frameborder="0" width="336" scrolling="no" height="280"></iframe>
[j2me] Nokia S60如何处理302 HTTP状态
<shapetype id="_x0000_t75" coordsize="21600,21600" o:spt="75" o:preferrelative="t" path="m@4@5l@4@11@9@11@9@5xe" filled="f" stroked="f"><stroke joinstyle="miter"></stroke><formulas><f eqn="if lineDrawn pixelLineWidth 0"></f><f eqn="sum @0 1 0"></f><f eqn="sum 0 0 @1"></f><f eqn="prod @2 1 2"></f><f eqn="prod @3 21600 pixelWidth"></f><f eqn="prod @3 21600 pixelHeight"></f><f eqn="sum @0 0 1"></f><f eqn="prod @6 1 2"></f><f eqn="prod @7 21600 pixelWidth"></f><f eqn="sum @8 21600 0"></f><f eqn="prod @7 21600 pixelHeight"></f><f eqn="sum @10 21600 0"></f></formulas><path o:extrusionok="f" gradientshapeok="t" o:connecttype="rect"></path><lock v:ext="edit" aspectratio="t"></lock></shapetype><shape id="_x0000_i1025" style="WIDTH: 450.1pt; HEIGHT: 8.45pt" type="#_x0000_t75" o:hrpct="0" o:hralign="center" o:hr="t"><imagedata src="file:///C:/DOCUME~1/ZHENGY~1.VIC/LOCALS~1/Temp/msohtml1/01/clip_image001.gif" o:title="BD10290_"></imagedata></shape>
历史
Version | Date | Creator | Description |
1.0.0.1 | 2006-7-24 | 郑昀 | 第一稿 |
1 Nokia S60如何处理302HTTP状态
HttpConnection/302/ HTTP_TEMP_REDIRECT
关键词 | 详细描述 |
当用HttpConnection读取远端数据,而远端返回状态码302表示重定向时,继续调用openInputStream来读取输入流将会导致程序崩溃。 此种现象发生在以下机型: Nokia N90/ 6600/6630/6680。 N70不会崩溃但也不会正常运行。 | 根据协议规定,此时的Location头域中保存了你应该重新请求的地址。 请看 http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.3.3 来了解更多关于"302 Found"。 也就是说,此时用HttpConnection.getHeaderField("Location")来得到具体的跳转url,然后重新向新地址发起请求。 代码示范: private HttpConnection open(String url) throws IOException { HttpConnection c; int status = -1; // Open the connection and check for redirects while (true) { c = (HttpConnection) Connector.open(url); // Get the status code, // causing the connection to be made status = c.getResponseCode(); if ((status == HttpConnection.HTTP_TEMP_REDIRECT) || (status == HttpConnection.HTTP_MOVED_TEMP) || (status == HttpConnection.HTTP_MOVED_PERM)) { // Get the new location and close the connection url = c.getHeaderField("location"); c.close(); } else { break; } } // Only HTTP_OK (200) means the content is returned. if (status != HttpConnection.HTTP_OK) { c.close(); throw new IOException("Response status not OK"); } return c; } |
| | |
参考资料1:RFC2616
10.3.3 302 Found
The requested resource resides temporarily under a different URI. Since the redirection might be altered on occasion, the client SHOULD continue to use the Request-URI for future requests. This response is only cacheable if indicated by a Cache-Control or Expires header field.
The temporary URI SHOULD be given by the Location field in the response. Unless the request method was HEAD, the entity of the response SHOULD contain a short hypertext note with a hyperlink to the new URI(s).
If the 302 status code is received in response to a request other than GET or HEAD, the user agent MUST NOT automatically redirect the request unless it can be confirmed by the user, since this might change the conditions under which the request was issued.
Note: RFC 1945 and RFC 2068 specify that the client is not allowed
to change the method on the redirected request. However, most
existing user agent implementations treat 302 as if it were a 303
response, performing a GET on the Location field-value regardless
of the original request method. The status codes 303 and 307 have
been added for servers that wish to make unambiguously clear which
kind of reaction is expected of the client.
参考资料2:Nokia Forum
KVM crashes when reading content with HTTP "302 Found" response on N90 and 6680
分享到:
相关推荐
good materials to learn s60 j2me UI development.
一款经典的j2me源码,可以在tooltik下运行,支持诺基亚s60的机子,便大家学习使用
在J2ME平台上,textfield设置为phonenumber,在一般的高端点手机,比如塞班s60上都会自动出现查找联系人的选项,而一些比较低端的nokia手机,将textfield里面的号码清空也会出现查找联系人的菜单(如果里面有号码这个...
原作者:亚日。共享出来方便大家。 以下载一张小图片为例子,一个较为简单的HTTP连接的demo。 支持CMNET及CMWAP两种不同的接入方式,以及在CMWAP接入方式下,过滤移动资费页面。在诺基亚 S60 系列真机上测试通过。
Java me 开发全屏的例子,适用于诺基亚s60系统
用j2me编写的 时区查看,选择 程序 附源代码,初学者请看
以篮球为竞技的争斗比赛,...诺基亚-*S60系列 7610,6620,3660,6600,3650,N70,N90,N91,6682,6680,6681,3230,6670,6260,6630,7650,SendoX,N93 索爱-*K700系列 K758c,K750c,K700c,W550c,k600i,v600i,w800c,W600c
基于Nokia S60的计算器,手机上的JAVA计算器accountsrc.rar
本文是博客《Windows 下安装 S60_3rd_sdk_fp2,并在 eclipse 上搭建 Nokia 的 J2ME 开发环境》示例源代码,博客地址:http://blog.csdn.net/defonds/archive/2010/01/30/5272933.aspx。
由Java2开发的j2me飞行射击类游戏范例源码,当时是为诺基亚的S60操作系统所写的机载游戏,当时是很牛逼了,可惜Nokia现在已经半死不活了,S60也过时了,不过若熟悉j2me游戏开发的话,向android的转变其实是很容易的...
一款手机学习英语的小软件。主要功能:手机词典(英汉互查)、生词本、单词测试、短文阅读、...支持手机类型:分辨率在240×320以上的手机均可,推荐使用Nokia S60 3rd。作者:广东岭南职业技术学院06NIIT班罗凌宇。
在诺基亚s60的模拟器下运行无误,有兴趣的朋友告诉我你的手机什么型号,能否运行。 本人刚学手机游戏,所以只是写了个简单的,只是可以玩的。还请大家多指教。这些天也不能美化一下了。(寝室就要没电了,而这几十天...
Nokia S60平台上操作蓝牙的示例代码。语言J2me
诺基亚手机j2me开发指引得中文翻译,翻译的不好,大家凑合看吧。
S60是新一代诺基亚的手机操作系统,娱乐功能很强大,不但有内置的高性能游戏,还可以通过手机自带的JAVA运行器运行其它手机版游戏,就像这款飞机游戏一样。可以安装在使用S60操作系统的手机上。 图片预览地址:...
Java教程,j2me手机游戏,j2me教程 主要是针对3D MotoRacer这款运行在手机上的游戏,这款游戏是Nokia S60及Sony Ericsson P800 (UIQ)的3D游戏,该游戏面市以来,风行全世界,成为采用Nokia S60操作系统、P800系统内置...
手机通讯录备份软件及源码都在上边 适合nokia s40及s60平台,使用到诺基亚的开发包 其他手机暂不支持 (内附源码 资源,及可执行jar文件) 开发环境eclipse sdk nokia S40 6th
Nokia官方的j2me基础中文教程,主要讲述MIDP2.0。
内容索引:JAVA源码,游戏娱乐,手机游戏,飞机游戏,J2ME游戏 S60是新一代诺基亚的手机操作系统,娱乐功能很强大,不但有内置的高性能游戏,还可以通过手机自带的JAVA运行器运行其它手机版游戏,就像这款飞机游戏一样。...
S40或S60是指诺基亚手机的上层平台。S60都是智能手机,所用底层操作系统是Symbian。诺基亚128*128屏幕都是S40 1.0。而128*160是S40 2.0。 另外S40中,3100支持java MIDP 1.0,所以最大支持64KB的java;6230支持...