| 460 | } |
| 461 | |
| 462 | static SC::Result sliceResponseBuffers(SC::Span<SC::HttpClientResponseBuffer> buffers, SC::Span<char> memory) |
| 463 | { |
| 464 | SC_TRY_MSG(not buffers.empty(), "HttpClientOperation: response buffers missing"); |
| 465 | SC_TRY_MSG(memory.sizeInBytes() >= buffers.sizeInElements(), |
| 466 | "HttpClientOperation: response buffer memory too small for slicing"); |
| 467 | |
| 468 | const size_t sliceSize = memory.sizeInBytes() / buffers.sizeInElements(); |
| 469 | SC_TRY_MSG(sliceSize > 0, "HttpClientOperation: response buffer slices would be empty"); |
| 470 | |
| 471 | for (size_t idx = 0; idx < buffers.sizeInElements(); ++idx) |
| 472 | { |
| 473 | buffers[idx].data = {memory.data() + (idx * sliceSize), |
| 474 | idx + 1 == buffers.sizeInElements() ? memory.sizeInBytes() - idx * sliceSize : sliceSize}; |
| 475 | } |
| 476 | return SC::Result(true); |
| 477 | } |
| 478 | } // namespace |
| 479 | |
| 480 | namespace |
no test coverage detected