Symbian(RSocket DownLoad)模拟HTTP下载
2010-10-20 07:59:57 来源:WEB开发网iDownloadSize+=iResponseChunk.Length();
iObserver->HandleHttpProgress(SizeL,
iDownloadSize);
iObserver->HandleWebData(iResponseChunk);
}
}
else
{//移动页进行二次请求
if (SecLink(iSecondUrl))
return;
}
iState = EReceiveMore;
iTimer.After(iStatus, 10000);
StartTimer(30);
SetActive();
}
break;
case EReceiveMore:
if (SizeL == iDownloadSize||iDownloadSize == curSizeL+1)//判
断数据是否下载完成
{
if(iDownloadSize < SizeL)
{
if (SecLink(iSecondUrl))
return;
}
Cancel();
iState = EComplete;
iTimer.After(iStatus, 1000);
StopTimer();
SetActive();
}
else//如果没有下载完成,继续准备接收数据
{
iState = EReceiving;
iResponseChunk.Zero() ;
iSocket.RecvOneOrMore(iResponseChunk, 0, iStatus,
iResponseChunkSizePkg) ;
SetActive();
}
break;
case EComplete:
{
//下载完成
iObserver->HandleWebDataCompleteL();
}
break;
}
}
}
//最重要的部分消息响应流程介绍完了.
//让我们来看看如何解析消息头的.哈哈.
_LIT8(KHttpHdrDiv, " ");
_LIT8(KHttpHdrEnd, " ");
TBool CWebClientEngine::ParseWebFileInfo(const TDesC8& recv_buf,
TInt& file_length, TInt& jump_len, TInt& status)
{
TBuf8<64> tmp_field;
TBuf8<64> tmp_end;
TBuf8<1024> tmp_str;
int find_pos;
status = 0;
//取状态码
tmp_field.Copy(_L8("HTTP/1.1 "));
tmp_end.Copy(KHttpHdrDiv) ;
更多精彩
赞助商链接