MCPcopy Create free account
hub / github.com/imroc/req / parseDataFrame

Function parseDataFrame

internal/http2/frame.go:655–687  ·  view source on GitHub ↗
(fc *frameCache, fh FrameHeader, countError func(string), payload []byte)

Source from the content-addressed store, hash-verified

653}
654
655func parseDataFrame(fc *frameCache, fh FrameHeader, countError func(string), payload []byte) (Frame, error) {
656 if fh.StreamID == 0 {
657 // DATA frames MUST be associated with a stream. If a
658 // DATA frame is received whose stream identifier
659 // field is 0x0, the recipient MUST respond with a
660 // connection error (Section 5.4.1) of type
661 // PROTOCOL_ERROR.
662 countError("frame_data_stream_0")
663 return nil, connError{ErrCodeProtocol, "DATA frame with stream ID 0"}
664 }
665 f := fc.getDataFrame()
666 f.FrameHeader = fh
667
668 var padSize byte
669 if fh.Flags.Has(FlagDataPadded) {
670 var err error
671 payload, padSize, err = readByte(payload)
672 if err != nil {
673 countError("frame_data_pad_byte_short")
674 return nil, err
675 }
676 }
677 if int(padSize) > len(payload) {
678 // If the length of the padding is greater than the
679 // length of the frame payload, the recipient MUST
680 // treat this as a connection error.
681 // Filed: https://github.com/http2/http2-spec/issues/610
682 countError("frame_data_pad_too_big")
683 return nil, connError{ErrCodeProtocol, "pad size larger than data payload"}
684 }
685 f.data = payload[:len(payload)-int(padSize)]
686 return f, nil
687}
688
689var (
690 errStreamID = errors.New("invalid stream ID")

Callers

nothing calls this directly

Calls 3

readByteFunction · 0.85
getDataFrameMethod · 0.80
HasMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…