MCPcopy Create free account
hub / github.com/apache/brpc / OnData

Method OnData

src/brpc/policy/http2_rpc_protocol.cpp:699–726  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

697}
698
699H2ParseResult H2Context::OnData(
700 butil::IOBufBytesIterator& it, const H2FrameHead& frame_head) {
701 uint32_t frag_size = frame_head.payload_size;
702 uint8_t pad_length = 0;
703 if (frame_head.flags & H2_FLAGS_PADDED) {
704 --frag_size;
705 pad_length = LoadUint8(it);
706 }
707 if (frag_size < pad_length) {
708 LOG(ERROR) << "Invalid payload_size=" << frame_head.payload_size;
709 return MakeH2Error(H2_FRAME_SIZE_ERROR);
710 }
711 frag_size -= pad_length;
712 H2StreamContext* sctx = FindStream(frame_head.stream_id);
713 if (sctx == NULL) {
714 // If a DATA frame is received whose stream is not in "open" or "half-closed (local)" state,
715 // the recipient MUST respond with a stream error (Section 5.4.2) of type STREAM_CLOSED.
716 // Ignore the message without closing the socket.
717 H2StreamContext tmp_sctx(false);
718 tmp_sctx.Init(this, frame_head.stream_id);
719 tmp_sctx.OnData(it, frame_head, frag_size, pad_length);
720 DeferWindowUpdate(tmp_sctx.ReleaseDeferredWindowUpdate());
721
722 LOG(ERROR) << "Fail to find stream_id=" << frame_head.stream_id;
723 return MakeH2Error(H2_STREAM_CLOSED_ERROR, frame_head.stream_id);
724 }
725 return sctx->OnData(it, frame_head, frag_size, pad_length);
726}
727
728H2ParseResult H2StreamContext::OnData(
729 butil::IOBufBytesIterator& it, const H2FrameHead& frame_head,

Callers

nothing calls this directly

Calls 15

LoadUint8Function · 0.85
MakeH2ErrorFunction · 0.85
SerializeFrameHeadFunction · 0.85
WriteAckFunction · 0.85
MakeH2MessageFunction · 0.85
append_and_forwardMethod · 0.80
forwardMethod · 0.80
backing_blockMethod · 0.80
fetch_addMethod · 0.80
SaveUint32Function · 0.70
InitMethod · 0.45

Tested by

no test coverage detected