Skip to content

Commit b0d6b89

Browse files
committed
Removing unnecessary sync() call from winrt http_client and exception check from desktop client.
1 parent 470a9f7 commit b0d6b89

File tree

2 files changed

+10
-15
lines changed

2 files changed

+10
-15
lines changed

Release/src/http/client/http_win7.cpp

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -835,20 +835,16 @@ class winhttp_client : public _http_client_communicator
835835
}
836836
_ASSERTE(read != static_cast<size_t>(-1));
837837

838-
if ( read == 0 )
838+
if (read == 0)
839839
{
840-
// Unexpected end-of-stream.
841-
if (!(rbuf.exception() == nullptr))
842-
p_request_context->report_exception(rbuf.exception());
843-
else
844-
p_request_context->report_error(GetLastError(), _XPLATSTR("Error reading outgoing HTTP body from its stream."));
840+
p_request_context->report_exception(http_exception(U("Unexpected end of request body stream encountered before Content-Length met.")));
845841
return;
846842
}
847843

848844
p_request_context->m_remaining_to_write -= read;
849845

850846
// Stop writing chunks after this one if no more data.
851-
if ( p_request_context->m_remaining_to_write == 0 )
847+
if (p_request_context->m_remaining_to_write == 0)
852848
{
853849
p_request_context->m_bodyType = no_body;
854850
}

Release/src/http/client/http_win8.cpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -279,16 +279,15 @@ class IResponseStream
279279
*pcbWritten = 0;
280280
}
281281

282+
if (cb == 0)
283+
{
284+
return S_OK;
285+
}
286+
282287
try
283288
{
284289
auto buffer = context->_get_writebuffer();
285-
if ( cb == 0 )
286-
{
287-
buffer.sync().wait();
288-
return S_OK;
289-
}
290-
291-
const size_t count = buffer.putn((const uint8_t *)pv, (size_t)cb).get();
290+
const size_t count = buffer.putn(reinterpret_cast<uint8_t *>(pv), static_cast<size_t>(cb)).get();
292291

293292
_ASSERTE(count != static_cast<size_t>(-1));
294293
_ASSERTE(count <= static_cast<size_t>(ULONG_MAX));
@@ -299,7 +298,7 @@ class IResponseStream
299298
context->m_downloaded += count;
300299

301300
auto progress = context->m_request._get_impl()->_progress_handler();
302-
if ( progress && count > 0 )
301+
if (progress && count > 0)
303302
{
304303
try { (*progress)(message_direction::download, context->m_downloaded); } catch(...)
305304
{

0 commit comments

Comments
 (0)