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

Method finalizeResponse

Libraries/Http/HttpAsyncClient.cpp:850–898  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

848}
849
850void HttpAsyncClient::onCompressedResponseBodyData(AsyncBufferView::ID bufferID)
851{
852 SC_HTTP_ASSERT_RELEASE(responseDecoder != nullptr);
853 Result writeResult = responseDecoder->AsyncWritableStream::write(
854 bufferID, {[this](AsyncBufferView::ID writtenBufferID) { onCompressedResponseBodyWritten(writtenBufferID); }});
855 if (not writeResult)
856 {
857 fail(writeResult);
858 }
859}
860
861void HttpAsyncClient::onCompressedResponseBodyWritten(AsyncBufferView::ID) {}
862
863void HttpAsyncClient::onCompressedResponseBodyEnd()
864{
865 SC_HTTP_ASSERT_RELEASE(responseDecoder != nullptr);
866 detachResponseDecompression();
867 responseDecoder->AsyncWritableStream::end();
868}
869
870void HttpAsyncClient::onCompressedResponseError(Result result) { fail(result); }
871
872void HttpAsyncClient::onHeadersBufferWritten(AsyncBufferView::ID)
873{
874 if (currentRequest == nullptr)
875 {
876 return;
877 }
878 if (currentRequest->getBodyType() == HttpAsyncClientRequest::BodyType::Stream)
879 {
880 connection->pipeline.source = currentRequest->getBodyStream();
881 connection->pipeline.transforms[0] = currentRequest->getBodyTransform();
882 connection->pipeline.transforms[1] = nullptr;
883 connection->pipeline.sinks[0] = &currentRequest->getWritableStream();
884 connection->pipeline.sinks[1] = nullptr;
885
886 Result res = connection->pipeline.pipe();
887 if (res)
888 {
889 res = connection->pipeline.start();
890 }
891 if (not res)
892 {
893 fail(res);
894 }
895 }
896 else if (currentRequest->getBodyType() == HttpAsyncClientRequest::BodyType::Span)
897 {
898 Result writeResult = connection->getWritableTransportStream().write(
899 AsyncBufferView(currentRequest->getBodySpan()),
900 {[this](AsyncBufferView::ID) { connection->getWritableTransportStream().end(); }});
901 if (not writeResult)

Callers

nothing calls this directly

Calls 2

finishBodyStreamMethod · 0.80
pauseMethod · 0.80

Tested by

no test coverage detected