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

Method onHeadersBufferWritten

Libraries/Http/HttpAsyncClient.cpp:598–687  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

596}
597
598void HttpAsyncClient::onCompressedResponseBodyWritten(AsyncBufferView::ID) {}
599
600void HttpAsyncClient::onCompressedResponseBodyEnd()
601{
602 SC_HTTP_ASSERT_RELEASE(responseDecoder != nullptr);
603 detachResponseDecompression();
604 responseDecoder->AsyncWritableStream::end();
605}
606
607void HttpAsyncClient::onCompressedResponseError(Result result) { fail(result); }
608
609void HttpAsyncClient::onHeadersBufferWritten(AsyncBufferView::ID)
610{
611 if (currentRequest == nullptr)
612 {
613 return;
614 }
615 if (currentRequest->getBodyType() == HttpAsyncClientRequest::BodyType::Stream)
616 {
617 connection->pipeline.source = currentRequest->getBodyStream();
618 connection->pipeline.transforms[0] = currentRequest->getBodyTransform();
619 connection->pipeline.transforms[1] = nullptr;
620 connection->pipeline.sinks[0] = &currentRequest->getWritableStream();
621 connection->pipeline.sinks[1] = nullptr;
622
623 Result res = connection->pipeline.pipe();
624 if (res)
625 {
626 res = connection->pipeline.start();
627 }
628 if (not res)
629 {
630 fail(res);
631 }
632 }
633 else if (currentRequest->getBodyType() == HttpAsyncClientRequest::BodyType::Span)
634 {
635 Result writeResult = connection->getWritableTransportStream().write(
636 AsyncBufferView(currentRequest->getBodySpan()),
637 {[this](AsyncBufferView::ID) { connection->getWritableTransportStream().end(); }});
638 if (not writeResult)
639 {
640 fail(writeResult);
641 }
642 }
643 else if (currentRequest->getBodyType() == HttpAsyncClientRequest::BodyType::Multipart)
644 {
645 static constexpr const char* HeaderSpaceFinished = "HttpAsyncClient header space is finished";
646
647 const HttpMultipartWriter& writer = *currentRequest->getMultipartWriter();
648 HttpFixedBufferWriter bodyWriter;
649 bodyWriter.reset(connection->getHeaderMemory());
650 const auto appendMultipartBody = [&]() -> Result
651 {
652 for (size_t idx = 0; idx < writer.getNumParts(); ++idx)
653 {
654 const HttpMultipartWriter::Part& part = writer.getPart(idx);
655 SC_TRY(bodyWriter.appendLiteral("--", HeaderSpaceFinished));

Callers

nothing calls this directly

Calls 11

AsyncBufferViewFunction · 0.85
getBoundaryMethod · 0.80
writtenMethod · 0.80
ResultClass · 0.50
pipeMethod · 0.45
startMethod · 0.45
writeMethod · 0.45
endMethod · 0.45
resetMethod · 0.45
appendMethod · 0.45
sizeInBytesMethod · 0.45

Tested by

no test coverage detected