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

Method onHeaderReady

Libraries/Http/HttpWebSocket.cpp:766–803  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

764}
765
766Result HttpWebSocketFrameReader::onHeaderReady()
767{
768 SC_TRY_MSG(currentFrame.masked == scHttpWebSocketRequiresIncomingMask(endpointRole),
769 "HttpWebSocketFrameReader invalid frame masking for endpoint role");
770
771 if (currentFrame.isControlFrame())
772 {
773 SC_TRY_MSG(currentFrame.fin, "HttpWebSocketFrameReader control frames must not be fragmented");
774 SC_TRY_MSG(currentFrame.payloadLength <= 125, "HttpWebSocketFrameReader control frame payload too large");
775 }
776 else
777 {
778 if (currentFrame.opcode == HttpWebSocketOpcode::Continuation)
779 {
780 SC_TRY_MSG(fragmentedMessageInProgress, "HttpWebSocketFrameReader unexpected continuation frame");
781 }
782 else
783 {
784 SC_TRY_MSG(not fragmentedMessageInProgress, "HttpWebSocketFrameReader expected continuation frame");
785 }
786 }
787
788 if (onFrameHeader.isValid())
789 {
790 SC_TRY(onFrameHeader(currentFrame));
791 }
792
793 payloadBytesRemaining = currentFrame.payloadLength;
794 payloadBytesConsumed = 0;
795
796 if (payloadBytesRemaining == 0)
797 {
798 return finishCurrentFrame();
799 }
800
801 state = State::Payload;
802 return Result(true);
803}
804
805Result HttpWebSocketFrameReader::finishCurrentFrame()
806{

Callers

nothing calls this directly

Calls 4

isControlFrameMethod · 0.80
ResultClass · 0.50
isValidMethod · 0.45

Tested by

no test coverage detected