本文整理汇总了C++中HttpRequest::GetDataSentEventHandler方法的典型用法代码示例。如果您正苦于以下问题:C++ HttpRequest::GetDataSentEventHandler方法的具体用法?C++ HttpRequest::GetDataSentEventHandler怎么用?C++ HttpRequest::GetDataSentEventHandler使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HttpRequest
的用法示例。
在下文中一共展示了HttpRequest::GetDataSentEventHandler方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ReadBody
size_t CurlHttpClient::ReadBody(char* ptr, size_t size, size_t nmemb, void* userdata)
{
CurlReadCallbackContext* context = reinterpret_cast<CurlReadCallbackContext*>(userdata);
if(context == nullptr)
{
return 0;
}
const CurlHttpClient* client = context->m_client;
if(!client->IsRequestProcessingEnabled())
{
return 0;
}
HttpRequest* request = context->m_request;
std::shared_ptr<Aws::IOStream> ioStream = request->GetContentBody();
if (ioStream != nullptr && size * nmemb)
{
size_t amountToRead = size * nmemb;
ioStream->read(ptr, amountToRead);
size_t amountRead = static_cast<size_t>(ioStream->gcount());
auto& sentHandler = request->GetDataSentEventHandler();
if (sentHandler)
{
sentHandler(request, static_cast<long long>(amountRead));
}
return amountRead;
}
return 0;
}
示例2: StreamPayloadToRequest
bool WinSyncHttpClient::StreamPayloadToRequest(const HttpRequest& request, void* hHttpRequest) const
{
bool success = true;
auto payloadStream = request.GetContentBody();
if(payloadStream)
{
auto startingPos = payloadStream->tellg();
char streamBuffer[ HTTP_REQUEST_WRITE_BUFFER_LENGTH ];
bool done = false;
while(success && !done)
{
payloadStream->read(streamBuffer, HTTP_REQUEST_WRITE_BUFFER_LENGTH);
std::streamsize bytesRead = payloadStream->gcount();
success = !payloadStream->bad();
uint64_t bytesWritten = 0;
if (bytesRead > 0)
{
bytesWritten = DoWriteData(hHttpRequest, streamBuffer, bytesRead);
if (!bytesWritten)
{
success = false;
}
}
auto& sentHandler = request.GetDataSentEventHandler();
if (sentHandler)
{
sentHandler(&request, (long long)bytesWritten);
}
if(!payloadStream->good())
{
done = true;
}
success = success && IsRequestProcessingEnabled();
}
payloadStream->clear();
payloadStream->seekg(startingPos, payloadStream->beg);
}
if(success)
{
success = DoReceiveResponse(hHttpRequest);
}
return success;
}