Fix bug on UWP request stream (#659)
This commit is contained in:
Родитель
be2fde89b0
Коммит
25864d6503
|
@ -51,6 +51,11 @@ HRESULT STDMETHODCALLTYPE http_request_stream::Read(
|
|||
_Out_ ULONG *pcbRead
|
||||
)
|
||||
{
|
||||
if (pv == nullptr || pcbRead == nullptr)
|
||||
{
|
||||
return STG_E_INVALIDPOINTER;
|
||||
}
|
||||
|
||||
HCHttpCallRequestBodyReadFunction readFunction = nullptr;
|
||||
size_t bodySize = 0;
|
||||
void* context = nullptr;
|
||||
|
@ -60,6 +65,13 @@ HRESULT STDMETHODCALLTYPE http_request_stream::Read(
|
|||
return STG_E_READFAULT;
|
||||
}
|
||||
|
||||
if (m_startIndex == bodySize)
|
||||
{
|
||||
// Reached end of buffer
|
||||
*pcbRead = 0;
|
||||
return S_FALSE;
|
||||
}
|
||||
|
||||
size_t bytesWritten = 0;
|
||||
try
|
||||
{
|
||||
|
@ -79,6 +91,11 @@ HRESULT STDMETHODCALLTYPE http_request_stream::Read(
|
|||
if (pcbRead != nullptr)
|
||||
{
|
||||
*pcbRead = static_cast<DWORD>(bytesWritten);
|
||||
if (bytesWritten < cb)
|
||||
{
|
||||
// Reached end of buffer
|
||||
return S_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
|
|
|
@ -40,11 +40,20 @@ HRESULT STDMETHODCALLTYPE http_response_stream::Write(
|
|||
try
|
||||
{
|
||||
hr = writeFunction(httpTask->call(), static_cast<const uint8_t*>(pv), cb, context);
|
||||
if (FAILED(hr))
|
||||
if (hr == E_OUTOFMEMORY)
|
||||
{
|
||||
return STG_E_MEDIUMFULL;
|
||||
}
|
||||
else if (FAILED(hr))
|
||||
{
|
||||
return STG_E_CANTSAVE;
|
||||
}
|
||||
}
|
||||
catch (std::bad_alloc /*e*/)
|
||||
{
|
||||
httpTask->set_exception(std::current_exception());
|
||||
return STG_E_MEDIUMFULL;
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
httpTask->set_exception(std::current_exception());
|
||||
|
|
Загрузка…
Ссылка в новой задаче