Symbian (Http DownLoad) Http 引擎下载实现
2010-02-08 03:06:00 来源:WEB开发网bHttpGetOrPost = EFalse;
StartTimer(30);
iSecondUrl.Copy(aUri);
// Parse string to URI (as defined in RFC2396)
TUriParser8 uri;
uri.Parse(aUri);
delete iPostData;
iPostData = aBody.AllocL();
#ifndef _DEBUG
if (bIAPIsWap)//设置WAP代理
{
TBuf8<20> aProxy8(_L8("10.0.0.172:80"));
RStringF iPrxAddr = iSession.StringPool().OpenFStringL(aProxy8);
CleanupClosePushL(iPrxAddr);
THTTPHdrVal iPrxUsage(iSession.StringPool().StringF
(HTTP::EUseProxy,RHTTPSession::GetTable()));
iSession.ConnectionInfo().SetPropertyL(iSession.StringPool().StringF
(HTTP::EProxyUsage,RHTTPSession::GetTable()), iPrxUsage);
iSession.ConnectionInfo().SetPropertyL(iSession.StringPool().StringF
(HTTP::EProxyAddress,RHTTPSession::GetTable()), iPrxAddr);
CleanupStack::PopAndDestroy();
}
#endif
RStringF method = iSession.StringPool().StringF(HTTP::EPOST,
RHTTPSession::GetTable());
// Open transaction with previous method and parsed uri. This class will
// receive transaction events in MHFRunL and MHFRunError.
iTransaction = iSession.OpenTransactionL(uri, *this, method);
// Set headers for request; user agent and accepted content type
RHTTPHeaders hdr = iTransaction.Request().GetHeaderCollection();
SetHeaderL(hdr, HTTP::EUserAgent, KUserAgent);
SetHeaderL(hdr, HTTP::EAccept, KAccept);
SetHeaderL( hdr, HTTP::EContentType, _L8("text/xml"));
TBuf8<64> sizeStr;
sizeStr.Format (_L8("bytes=%d-"),iDownloadSize);
sizeStr.AppendFormat (_L8("%d"),curSizeL);
SetHeaderL (hdr, HTTP::ERange, sizeStr);
MHTTPDataSupplier* dataSupplier = this;
iTransaction.Request().SetBody(*dataSupplier);
更多精彩
赞助商链接