WEB开发网
开发学院手机开发Symbian 开发 symbian 使用http get post方式获取网页信息 阅读

symbian 使用http get post方式获取网页信息

 2010-05-31 19:38:00 来源:WEB开发网   
核心提示:void CClientEngine::IssueHTTPGetL(const TDesC8& aUri)//以get方式获取一个网页 { SetupConnectionL(); // Parse string to URI (as defined in RFC2396) TUriParser8 uri; uri.Pa
void CClientEngine::IssueHTTPGetL(const TDesC8& aUri)//以get方式获取一个网页 { SetupConnectionL(); // Parse string to URI (as defined in RFC2396) TUriParser8 uri; uri.Parse(aUri);//把传入的uri转化为标准格式 // Get request method string for HTTP GET RStringF method = iSession.StringPool().StringF(HTTP::EGET, RHTTPSession::GetTable());//设置以get的方法读取 // Open transaction with previous method and parsed uri. This class will // receive transaction events in MHFRunL and MHFRunError. iTransaction = iSession.OpenTransactionL(uri, *this, method);//打开一个连接 使用设置好的方法和指定的uri // Set headers for request; user agent and accepted content type RHTTPHeaders hdr = iTransaction.Request().GetHeaderCollection();//设置一个http头 SetHeaderL(hdr, HTTP::EUserAgent, KUserAgent); SetHeaderL(hdr, HTTP::EAccept, KAccept); // Submit the transaction. After this the framework will give transaction // events via MHFRunL and MHFRunError. iTransaction.SubmitL();//调用 MHFRunL iRunning = ETrue; _LIT(KConnecting,"Connecting..."); iObserver.ClientEvent(KConnecting); } // ---------------------------------------------------------------------------- // CClientEngine::IssueHTTPPostL() // // Start a new HTTP POST transaction. // ---------------------------------------------------------------------------- void CClientEngine::IssueHTTPPostL(const TDesC8& aUri, const TDesC8& aContentType, const TDesC8& aBody) { SetupConnectionL(); // Parse string to URI TUriParser8 uri; uri.Parse(aUri); // Copy data to be posted into member variable; iPostData is used later in // methods inherited from MHTTPDataSupplier. delete iPostData; iPostData = aBody.AllocL();//把取得的数据放到iPostData里 // Get request method string for HTTP POST RStringF method = iSession.StringPool().StringF(HTTP::EPOST,//设置post方法 RHTTPSession::GetTable()); // Open transaction with previous method and parsed uri. This class will // receive transaction events in MHFRunL and MHFRunError.

上一页  12 13 14 15 16 17 18 19 20 21 22  下一页

Tags:symbian 使用 http

编辑录入:coldstar [复制链接] [打 印]
赞助商链接