当前位置: 首页>>代码示例>>C++>>正文


C++ HttpRequest::GetDataSentEventHandler方法代码示例

本文整理汇总了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;
}
开发者ID:rikust,项目名称:aws-sdk-cpp,代码行数:33,代码来源:CurlHttpClient.cpp

示例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;
}
开发者ID:Bu11etmagnet,项目名称:aws-sdk-cpp,代码行数:50,代码来源:WinSyncHttpClient.cpp


注:本文中的HttpRequest::GetDataSentEventHandler方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。