symbian 使用http get post方式获取网页信息
2010-05-31 19:38:00 来源:WEB开发网核心提示:the response. However, it's not // necessary to do anything with the response when this event occurs. // Get HTTP status code from header (e.g. 200) RHTTPRe
the response. However, it's not // necessary to do anything with the response
when this event occurs. // Get HTTP status code from header (e.g. 200)
RHTTPResponse resp = aTransaction.Response(); TInt status = resp.StatusCode();
// Get status text (e.g. "OK") TBuf< KStatustextBufferSize > statusText;
statusText.Copy(resp.StatusText().DesC()); TBuf< KDefaultBufferSize >
text; _LIT(KHeaderReceived, "Header received. Status: %d %S");
text.Format(KHeaderReceived, status, &statusText);
iObserver.ClientEvent(text); } break; case THTTPEvent::EGotResponseBodyData: {
// Part (or all) of response's body data received. Use //
aTransaction.Response().Body()- >GetNextDataPart() to get the actual // body
data. // Get the body data supplier MHTTPDataSupplier* body =
aTransaction.Response().Body(); TPtrC8 dataChunk; // GetNextDataPart() returns
ETrue, if the received part is the last // one. TBool isLast = body-
>GetNextDataPart(dataChunk);
iObserver.ClientBodyReceived(dataChunk);//把得到的数据包写进上半部分 TBuf<
KInfotextBufferSize > text; _LIT(KBodyPartReceived, "%d bytes received... ");
text.Format(KBodyPartReceived, dataChunk.Length()); iObserver.ClientEvent(text);
// NOTE: isLast may not be ETrue even if last data part received. // (e.g.
multipart response without content length field) // Use EResponseComplete to
reliably determine when body is completely // received. if (isLast) {
_LIT(KBodyReceived,"Body received"); iObserver.ClientEvent(KBodyReceived); } //
Always remember to release the body data. body- >ReleaseData(); } break; case
THTTPEvent::EResponseComplete: { // Indicates that header & body of response
is completely received. // No further action here needed.
_LIT(KTransactionComplete, "Transaction Complete");
iObserver.ClientEvent(KTransactionComplete); } break; case
THTTPEvent::ESucceeded: { // Indicates that transaction succeeded.
_LIT(KTransactionSuccessful, "Transaction Successful");
更多精彩
赞助商链接