Join Now
Quality Rating:
  • Currently 0.0 / 5
(0.0 / 5 - 0 votes cast)
Expertise Level:
  • Currently 0.0 / 5
(0.0 / 5 - 0 votes cast)

This page was last modified 19:02, 24 June 2008.

Series 60 2nd/3rd上处理HTTP通讯中302跳转的方法

From Forum Nokia Wiki

在使用Symbian提供的HTTP引擎时发现,在网络返回302跳转消息时获取跳转的URL为空(”Location”),这种情况在Series 60 2nd和3rd都存在。要解决这个问题需要首先了解一下HTTP引擎本身提供过滤机制(Filter),这种机制可以为实际应用中的各种HTTP消息响应机制提供支持,通过这个机制可以为HTTP引擎添加/删除某个过滤器,当然我们也可以实现自己的过滤器。之所以取到的跳转URL为空,就是因为HTTP引擎默认情况添加了302跳转的过滤器,如果程序中需要自己处理的话就需要把这个过滤器从当前的HTTP会话中删除掉,下面的代码演示了删除过滤器的方法:

void CHTTPEngine::ConstructL()
{
       // Open RHTTPSession with default protocol ("HTTP/TCP")
       TRAPD(err, iSession.OpenL());
       if(err != KErrNone) 
       {
              // Most common error; no access point configured, and session creation
              // leaves with KErrNotFound.
              _LIT(KErrMsg,
                     "Cannot create session. Is internet access point configured?");
              _LIT(KExitingApp, "Exiting app.");
              CEikonEnv::Static()->InfoWinL(KErrMsg, KExitingApp);
              User::Leave(err);
       }
 
       //Remove the redirect filter.
       RStringPool pool = iSession.StringPool();
       iSession.FilterCollection().RemoveFilter( pool.StringF( HTTP::ERedirect, RHTTPSession::GetTable() ) );
 
       …………………………
}

使用上面的方法去掉HTTP会话中的跳转过滤后就可以正常响应和处理302跳转了。该代码在Series 60 2nd和3rd平台上测试通过。

Related Discussions
Thread Thread Starter Forum Replies Last Post
J2me Midlet running problem in Symbian nokia mobile series 60 & upwords sumanbera Mobile Java General 7 2007-01-18 09:46
Older S40 SDKs Manthatufear Mobile Java Tools & SDKs 9 2008-04-18 17:35
First step into development) maxkazar Symbian Tools & SDKs 8 2007-05-24 16:56
Hindi font in series 60 2nd Editon FP3 sdk Sohil General Symbian C++ 25 2007-04-09 11:27
如果发送短信和拨打电话 jackjojo Symbian 1 2006-04-09 04:24
 
Powered by MediaWiki
     
     RDF Facets:
     
     
     qfnZtypeQUqfnTypeZCommunityContentQ
     qfnZtypeQUqfnTypeZWebpageQ
     qfnZtypeQUqfnTypeZWikiContentQ
     qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX