本文整理汇总了C++中CHttpFile::Flush方法的典型用法代码示例。如果您正苦于以下问题:C++ CHttpFile::Flush方法的具体用法?C++ CHttpFile::Flush怎么用?C++ CHttpFile::Flush使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CHttpFile
的用法示例。
在下文中一共展示了CHttpFile::Flush方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetHTTPData
//.........这里部分代码省略.........
line = "request failed - the redirected URL does not reference a HTTP resource";
}
// try again at the new location
pServer = session.GetHttpConnection(strServerName, nPort);
if(!b_post) {
pFile = pServer->OpenRequest(CHttpConnection::HTTP_VERB_GET, strObject);
}
else {
pFile = pServer->OpenRequest(CHttpConnection::HTTP_VERB_POST, file.c_str());
}
//pFile->AddRequestHeaders(szHeaders);
pFile->SendRequest();
pFile->QueryInfoStatusCode(dwRet);
if (dwRet != HTTP_STATUS_OK)
{
TRACE(_T("Error: Got status code %d\n"), dwRet);
line = "request failed - Got status code " + dwRet;
}
}
CString content_type = "";
pFile->QueryInfo(HTTP_QUERY_RAW_HEADERS_CRLF , content_type);
if(content_type.Find(": gzip") > 0) isGzipped = true;
const int read_size = 1024;
TCHAR sz[read_size+1];
UINT nRead = pFile->Read(sz, read_size);
int curPos = 0;
size = nRead;
int cur_size = 10240;
buf = new unsigned short[cur_size];
while (nRead > 0)
{
if(size > cur_size) {
int new_size = cur_size * 2;
unsigned short *temp = new unsigned short[new_size];
for(int i = 0; i < cur_size; i++) {
temp[i] = buf[i];
}
delete [] buf;
buf = temp;
cur_size = new_size;
}
for(UINT i = 0; i < nRead; i++) {
buf[i+curPos] = sz[i];
}
curPos += nRead;
nRead = pFile->Read(sz, read_size);
size += nRead;
}
unsigned short * temp = new unsigned short[size+1];
for(int i = 0; i < size; i++) {
temp[i] = buf[i];
}
delete [] buf;
buf = temp;
SetCookie(&session, strServerName);
SetCookie(&session, url);
}
catch (exception e) {
TRACE(e.what());
line = "request failed - status code N/A";
}
catch (CInternetException * e) {
TCHAR error[256];
if(e->GetErrorMessage(error, 256)) {
//TRACE("URL: '%s'\n", url);
TRACE("%s\n", error);
}
e->Delete();
e = NULL;
line = "request failed - status code N/A";
}
if(pFile != NULL) {
pFile->Flush();
pFile->Close();
delete pFile;
pFile = NULL;
}
if(pServer != NULL) {
pServer->Close();
delete pServer;
pServer = NULL;
}
if(isGzipped) {
unsigned short *data = NULL;
size = UnZip(&data, buf, size);
if(size == 0) {
delete [] data;
data = NULL;
}
delete [] buf;
*body = data;
}
else *body = buf;
return size;
}