Symbian(RSocket DownLoad)模拟HTTP下载
2010-10-20 07:59:57 来源:WEB开发网#else
iServerName.Copy(_L("10.0.0.172"));
#endif
}
if (sPort.Length() == 0)
{
port = 80;
}
else
{
TLex8 iLex;
iLex = sPort;
iLex.Val(port);
if(port == 0)
{
port = 80;
}
}
//组装HTTP请求头
if (iRequest)
{
delete iRequest;
iRequest = NULL;
}
iRequest = HBufC8::NewL(1024);
iRequest->Des().AppendFormat(_L8("POST %S HTTP/1.1 "),&iSecondUrl);
#ifdef _DEBUG
iRequest->Des().AppendFormat(_L8("Host:%S "),&sHost);
#else
if(isWap)
{
iRequest->Des().AppendFormat(_L8("Host:%S "),&_L8("10.0.0.172"));
}
else
{
iRequest->Des().AppendFormat(_L8("Host:%S "),&sHost);
}
#endif
iRequest->Des().AppendFormat(_L8("X-Online-Host:%S "),&sHost);
iRequest->Des().Append(_L8("User-Agent: myhttpClient 1.0 "));
iRequest->Des().Append(_L8("Accept: */* Range: bytes="));
//设置断点续传
iRequest->Des().AppendNum(size);
iRequest->Des().Append(_L8("-"));
iRequest->Des().AppendNum(size+MAXDOWNLOADSIZE);
iRequest->Des().Append(_L8(" "));
iRequest->Des().Append(_L8("Content-Length: 0 "));
iRequest->Des().Append(_L8("Cache-Control: no-cache "));
iRequest->Des().Append(_L8("Connection: Close "));
//dns 解析
User::LeaveIfError(iResolver.Open(iSockServer, KAfInet, KProtocolInetTcp,
iConnection));
iResolver.GetByName(iServerName, iHostAddress, iStatus);
iState = EResolving;
isRunning = true;
赞助商链接