本文整理汇总了C++中CComObject::GetOffset方法的典型用法代码示例。如果您正苦于以下问题:C++ CComObject::GetOffset方法的具体用法?C++ CComObject::GetOffset怎么用?C++ CComObject::GetOffset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CComObject
的用法示例。
在下文中一共展示了CComObject::GetOffset方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnSendResponse
//.........这里部分代码省略.........
BYTE* pbyData = (BYTE*) pHttpContext->AllocateRequestMemory(dwContentLength);
if (pbyData != NULL)
{
// copy the response data
memcpy(pbyData, pEntityChunk->FromMemory.pBuffer, pEntityChunk->FromMemory.BufferLength);
// change the buffer pointer
pEntityChunk->FromMemory.pBuffer = pbyData;
}
else
{
hr = E_OUTOFMEMORY;
}
}
// allocate the response stream
CComPtr<IStream> pStream;
CComObject<CResponseStream>* pResponseStream = NULL;
if (hr == S_OK)
{
hr = CComObject<CResponseStream>::CreateInstance(&pResponseStream);
if (hr == S_OK)
{
pStream = pResponseStream;
}
}
// catch any memory issues
if (FAILED(hr) == TRUE)
{
// abort the compression
pIISxpressHTTPRequest->AbortRequest(dwFilterContext);
// TODO: need to handle generic HRs
PerfCountersAddRejectedResponse(hr);
AppendLogMessage(IISXPRESS_LOGGINGLEVEL_BASIC, pszMethodName, pHttpContext, _T("won't handle response (0x%08x)\n"), hr);
return RQ_NOTIFICATION_CONTINUE;
}
pResponseStream->AttachBuffer(pEntityChunk->FromMemory.pBuffer, dwContentLength, 0);
char szContentEncoding[32] = "";
hr = pIISxpressHTTPRequest->OnSendRawData(dwFilterContext, pStream, dwContentLength, FALSE, (signed char*) szContentEncoding, _countof(szContentEncoding));
if (hr == S_OK)
{
DWORD dwOriginalSize = dwContentLength;
DWORD dwCompressedSize = pResponseStream->GetOffset();
// set the new content length into the header
CAtlStringA sContentLength;
sContentLength.Format("%u", dwCompressedSize);
pHttpResponse->SetHeader(HttpHeaderContentLength, sContentLength, (USHORT) sContentLength.GetLength(), TRUE);
// set the new size into the buffer
pRawResponse->pEntityChunks->FromMemory.BufferLength = dwCompressedSize;
pHttpResponse->SetHeader(HttpHeaderContentEncoding, szContentEncoding, (USHORT) strlen(szContentEncoding), TRUE);
// add the item to the cache if we have a key (it means the data is cachable)
if (dwCompressedSize < dwOriginalSize &&
m_nCacheEnabled != 0 && sCacheKey.GetLength() > 0)
{
ResponseCacheItem* pCacheItem = new ResponseCacheItem();
if (pCacheItem != NULL)
{
pCacheItem->sContentEncoding = szContentEncoding;
pCacheItem->sContentLength = sContentLength;
pCacheItem->dwContentLength = dwCompressedSize;
pCacheItem->pbyData = new BYTE[dwCompressedSize];
if (pCacheItem->pbyData != NULL)
{
// copy the compressed data and add it to the cache
memcpy(pCacheItem->pbyData, pEntityChunk->FromMemory.pBuffer, dwCompressedSize);
m_ResponseCache.Add(sCacheKey, pCacheItem, pCacheItem->dwContentLength, NULL, NULL, NULL, m_ResponseCacheItemDeallocator);
PerfCountersUpdateCacheStatus(true);
}
}
}
PerfCountersAddCompressedResponse(dwContentLength, dwCompressedSize);
// make sure the context is released
hr = pIISxpressHTTPRequest->OnEndOfRequest(dwFilterContext, NULL, 0, FALSE, NULL, 0);
}
else
{
// abort the compression
pIISxpressHTTPRequest->AbortRequest(dwFilterContext);
// TODO: need to handle generic HRs
PerfCountersAddRejectedResponse(hr);
AppendLogMessage(IISXPRESS_LOGGINGLEVEL_BASIC, pszMethodName, pHttpContext, _T("won't handle response (0x%08x)\n"), hr);
}
return RQ_NOTIFICATION_CONTINUE;
}