MCPcopy Create free account
hub / github.com/Pagghiu/SaneCppLibraries / asyncWrite

Method asyncWrite

Libraries/Http/HttpConnection.cpp:839–855  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

837}
838
839Result HttpOutgoingMessage::ChunkedWritableStream::asyncWrite(AsyncBufferView::ID bufferID,
840 Function<void(AsyncBufferView::ID)> cb)
841{
842 SC_TRY_MSG(destination != nullptr, "HttpOutgoingMessage chunked destination missing");
843
844 Span<const char> body;
845 SC_TRY(getBuffersPool().getReadableData(bufferID, body));
846
847 StringSpan header;
848 SC_TRY(scHttpFormatChunkHeader(static_cast<uint64_t>(body.sizeInBytes()), headerStorage, header));
849
850 currentBodyBufferID = bufferID;
851 currentBodyCallback = move(cb);
852 getBuffersPool().refBuffer(bufferID);
853 return destination->write(AsyncBufferView(header.toCharSpan()),
854 {[this](AsyncBufferView::ID writtenBufferID) { onChunkHeaderWritten(writtenBufferID); }});
855}
856
857bool HttpOutgoingMessage::ChunkedWritableStream::canEndWritable()
858{

Callers

nothing calls this directly

Calls 6

scHttpFormatChunkHeaderFunction · 0.85
AsyncBufferViewFunction · 0.85
getReadableDataMethod · 0.80
refBufferMethod · 0.80
sizeInBytesMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected