symbian 使用http get post方式获取网页信息
2010-05-31 19:38:00 来源:WEB开发网核心提示:iTransaction = iSession.OpenTransactionL(uri, *this, method); // Set headers for request; user agent, accepted content type and body's // content type. RHTT
iTransaction = iSession.OpenTransactionL(uri, *this, method); // Set headers for
request; user agent, accepted content type and body's // content type.
RHTTPHeaders hdr = iTransaction.Request().GetHeaderCollection(); SetHeaderL(hdr,
HTTP::EUserAgent, KUserAgent); SetHeaderL(hdr, HTTP::EAccept, KAccept);
SetHeaderL(hdr, HTTP::EContentType, aContentType); // Set this class as an data
supplier. Inherited MHTTPDataSupplier methods // are called when framework needs
to send body data. MHTTPDataSupplier* dataSupplier = this;
iTransaction.Request().SetBody(*dataSupplier);//设置提交的数据 // Submit the
transaction. After this the framework will give transaction // events via
MHFRunL and MHFRunError. iTransaction.SubmitL(); iRunning = ETrue;
_LIT(KConnecting,"Connecting..."); iObserver.ClientEvent(KConnecting); } //
---------------------------------------------------------------------------- //
CClientEngine::CancelTransaction() // // Cancels currently running transaction
and frees resources related to it. //
----------------------------------------------------------------------------
void CClientEngine::CancelTransaction() { if(!iRunning) return; // Close() also
cancels transaction (Cancel() can also be used but // resources allocated by
transaction must be still freed with Close()) iTransaction.Close(); // Not
running anymore iRunning = EFalse; _LIT(KTransactionCancelled, "Transaction
cancelled"); iObserver.ClientEvent(KTransactionCancelled); } //
---------------------------------------------------------------------------- //
CClientEngine::MHFRunL() // // Inherited from MHTTPTransactionCallback // Called
by framework to pass transaction events. //
----------------------------------------------------------------------------
void CClientEngine::MHFRunL(RHTTPTransaction aTransaction, const THTTPEvent&
aEvent) { switch (aEvent.iStatus) { case THTTPEvent::EGotResponseHeaders: { //
HTTP response headers have been received. Use // aTransaction.Response() to get
更多精彩
赞助商链接