@@ -1231,37 +1231,22 @@ class winhttp_client : public _http_client_communicator
12311231 }
12321232
12331233 auto writebuf = p_request_context->_get_writebuffer ();
1234- if ( !_check_streambuf (p_request_context, writebuf, _XPLATSTR (" Output stream is not open" )) )
1235- break ;
1236-
1237- auto after_sync =
1238- [hRequestHandle, p_request_context]
1239- (pplx::task<void > sync_op)
1234+
1235+ if ( p_request_context->is_externally_allocated () )
12401236 {
1241- try { sync_op.wait (); } catch (...)
1242- {
1243- p_request_context->report_exception (std::current_exception ());
1244- return ;
1245- }
1237+ writebuf.commit (statusInfoLength);
12461238
12471239 // Look for more data
1248- if ( !WinHttpQueryDataAvailable (hRequestHandle, nullptr ))
1240+ if ( !WinHttpQueryDataAvailable (hRequestHandle, nullptr ))
12491241 {
12501242 p_request_context->report_error (GetLastError (), _XPLATSTR (" Error querying for http body chunk" ));
12511243 return ;
12521244 }
1253- };
1254-
1255- if ( p_request_context->is_externally_allocated () )
1256- {
1257- writebuf.commit (statusInfoLength);
1258-
1259- writebuf.sync ().then (after_sync);
12601245 }
12611246 else
12621247 {
12631248 writebuf.putn (p_request_context->m_body_data .get (), statusInfoLength).then (
1264- [hRequestHandle, p_request_context, statusInfoLength, after_sync ]
1249+ [hRequestHandle, p_request_context, statusInfoLength]
12651250 (pplx::task<size_t > op)
12661251 {
12671252 size_t written = 0 ;
@@ -1278,11 +1263,12 @@ class winhttp_client : public _http_client_communicator
12781263 return ;
12791264 }
12801265
1281- auto wbuf = p_request_context->_get_writebuffer ();
1282- if ( !_check_streambuf (p_request_context, wbuf, _XPLATSTR (" Output stream is not open" )) )
1266+ // Look for more data
1267+ if (!WinHttpQueryDataAvailable (hRequestHandle, nullptr ))
1268+ {
1269+ p_request_context->report_error (GetLastError (), _XPLATSTR (" Error querying for http body chunk" ));
12831270 return ;
1284-
1285- wbuf.sync ().then (after_sync);
1271+ }
12861272 });
12871273 }
12881274 }
0 commit comments