@@ -340,7 +340,6 @@ class DataSink {
340
340
341
341
std::function<bool (const char *data, size_t data_len)> write;
342
342
std::function<void ()> done;
343
- std::function<bool ()> is_writable;
344
343
std::ostream os;
345
344
346
345
private:
@@ -3632,7 +3631,7 @@ inline bool write_content(Stream &strm, const ContentProvider &content_provider,
3632
3631
3633
3632
data_sink.write = [&](const char *d, size_t l) -> bool {
3634
3633
if (ok) {
3635
- if (write_data (strm, d, l)) {
3634
+ if (!strm. is_writable () || write_data (strm, d, l)) {
3636
3635
offset += l;
3637
3636
} else {
3638
3637
ok = false ;
@@ -3641,8 +3640,6 @@ inline bool write_content(Stream &strm, const ContentProvider &content_provider,
3641
3640
return ok;
3642
3641
};
3643
3642
3644
- data_sink.is_writable = [&](void ) { return ok && strm.is_writable (); };
3645
-
3646
3643
while (offset < end_offset && !is_shutting_down ()) {
3647
3644
if (!content_provider (offset, end_offset - offset, data_sink)) {
3648
3645
error = Error::Canceled;
@@ -3680,15 +3677,13 @@ write_content_without_length(Stream &strm,
3680
3677
data_sink.write = [&](const char *d, size_t l) -> bool {
3681
3678
if (ok) {
3682
3679
offset += l;
3683
- if (!write_data (strm, d, l)) { ok = false ; }
3680
+ if (!strm. is_writable () || ! write_data (strm, d, l)) { ok = false ; }
3684
3681
}
3685
3682
return ok;
3686
3683
};
3687
3684
3688
3685
data_sink.done = [&](void ) { data_available = false ; };
3689
3686
3690
- data_sink.is_writable = [&](void ) { return ok && strm.is_writable (); };
3691
-
3692
3687
while (data_available && !is_shutting_down ()) {
3693
3688
if (!content_provider (offset, 0 , data_sink)) { return false ; }
3694
3689
if (!ok) { return false ; }
@@ -3720,7 +3715,7 @@ write_content_chunked(Stream &strm, const ContentProvider &content_provider,
3720
3715
// Emit chunked response header and footer for each chunk
3721
3716
auto chunk =
3722
3717
from_i_to_hex (payload.size ()) + " \r\n " + payload + " \r\n " ;
3723
- if (!write_data (strm, chunk.data (), chunk.size ())) { ok = false ; }
3718
+ if (!strm. is_writable () || ! write_data (strm, chunk.data (), chunk.size ())) { ok = false ; }
3724
3719
}
3725
3720
} else {
3726
3721
ok = false ;
@@ -3759,8 +3754,6 @@ write_content_chunked(Stream &strm, const ContentProvider &content_provider,
3759
3754
}
3760
3755
};
3761
3756
3762
- data_sink.is_writable = [&](void ) { return ok && strm.is_writable (); };
3763
-
3764
3757
while (data_available && !is_shutting_down ()) {
3765
3758
if (!content_provider (offset, 0 , data_sink)) {
3766
3759
error = Error::Canceled;
@@ -6544,8 +6537,6 @@ inline std::unique_ptr<Response> ClientImpl::send_with_content_provider(
6544
6537
return ok;
6545
6538
};
6546
6539
6547
- data_sink.is_writable = [&](void ) { return ok && true ; };
6548
-
6549
6540
while (ok && offset < content_length) {
6550
6541
if (!content_provider (offset, content_length - offset, data_sink)) {
6551
6542
error = Error::Canceled;
@@ -6717,7 +6708,6 @@ inline ContentProviderWithoutLength ClientImpl::get_multipart_content_provider(
6717
6708
bool has_data = true ;
6718
6709
cur_sink.write = sink.write ;
6719
6710
cur_sink.done = [&]() { has_data = false ; };
6720
- cur_sink.is_writable = sink.is_writable ;
6721
6711
6722
6712
if (!provider_items[cur_item].provider (offset - cur_start, cur_sink))
6723
6713
return false ;
0 commit comments