Symbian (Http DownLoad) Http 引擎下载实现
2010-02-08 03:06:00 来源:WEB开发网// Submit the transaction. After this the framework will give transaction
// events via MHFRunL and MHFRunError.
iTransaction.SubmitL();
iRunning = ETrue;
}
//请求完成后,事物的相关事件都会回调
void CWebClientEngine::MHFRunL(RHTTPTransaction aTransaction,
const THTTPEvent& aEvent)
{
switch (aEvent.iStatus)
{
//响应消息头
case THTTPEvent::EGotResponseHeaders:
{
RHTTPResponse resp = aTransaction.Response();
TInt status = resp.StatusCode();
if (status == 200 || status == 206)
{
//成功连接的情况下,解析头.
DumpRespHeadersL(aTransaction);
iObserver->HandleWebDataStart();
}
else if (status >= 300 && status <= 399)
{
iRunning = EFalse;
//发生跳转时,得到跳转地址
GetLocationL(aTransaction);
iDownloadSize = 0;
//得到跳转地址后,重新请求
StartGetClient(m_Location,iDownloadSize);
break;
}
else
{
//发生异常,关闭事物
iTransaction.Close();
iRunning = EFalse;
break;
}
}
break;
case THTTPEvent::EGotResponseBodyData:
{
//响应消息体
// Get the body data supplier
MHTTPDataSupplier* body = aTransaction.Response().Body();
TPtrC8 dataChunk;
TBool isLast = body->GetNextDataPart(dataChunk);
RLog::LogPoor(_L("isLast = "),isLast);
DataLength = dataChunk.Length();
bIsReciveData = ETrue;
if(bIAPIsWap)//如果是WAP接入点.我们需要判断移动拦截页面
{
//如果是移动拦截页,再次请求
TBool err = CheckRecv(dataChunk);
RLog::LogPoor(_L("err = "),err);
更多精彩
赞助商链接