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 if (response.isBodyComplete())
850 {
851 const bool removed =
852 connection->getReadableTransportStream()
853 .eventData.removeListener<HttpAsyncClient, &HttpAsyncClient::onResponseBodyData>(*this);
854 (void)(removed);
855 finishResponse();
856 }
857}
858
859void HttpAsyncClient::finishResponse() { finalizeResponse(true); }
860
861void HttpAsyncClient::finalizeResponse(bool shouldFinishBodyStream)
862{
863 if (responseFinalized)
864 {
865 return;
866 }
867 responseFinalized = true;
868
869 requestCount++;
870
871 if (webSocketUpgraded)
872 {
873 state = State::Idle;
874 currentRequest = nullptr;
875 if (shouldFinishBodyStream)
876 {
877 response.finishBodyStream();
878 }
879 return;
880 }
881
882 const bool keepAlive = currentRequest != nullptr and currentRequest->getKeepAlive() and response.getKeepAlive() and
883 response.getBodyFramingKind() != HttpBodyFramingKind::CloseDelimited;
884
885 if (keepAlive)
886 {
887 connection->getReadableTransportStream().pause();
888 }
889 else
890 {
891 hasOpenConnection = false;
892 currentProtocol = {};
893 currentHost = {};
894 currentPort = 0;
895 }
896
897 state = State::Idle;
898 currentRequest = nullptr;
899
900 if (shouldFinishBodyStream)
901 {

Callers

nothing calls this directly

Calls 2

finishBodyStreamMethod · 0.80
pauseMethod · 0.80

Tested by

no test coverage detected