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

Function parseHeadersFrame

internal/http2/frame.go:1078–1118  ·  view source on GitHub ↗
(_ *frameCache, fh FrameHeader, countError func(string), p []byte)

Source from the content-addressed store, hash-verified

1076}
1077
1078func parseHeadersFrame(_ *frameCache, fh FrameHeader, countError func(string), p []byte) (_ Frame, err error) {
1079 hf := &HeadersFrame{
1080 FrameHeader: fh,
1081 }
1082 if fh.StreamID == 0 {
1083 // HEADERS frames MUST be associated with a stream. If a HEADERS frame
1084 // is received whose stream identifier field is 0x0, the recipient MUST
1085 // respond with a connection error (Section 5.4.1) of type
1086 // PROTOCOL_ERROR.
1087 countError("frame_headers_zero_stream")
1088 return nil, connError{ErrCodeProtocol, "HEADERS frame with stream ID 0"}
1089 }
1090 var padLength uint8
1091 if fh.Flags.Has(FlagHeadersPadded) {
1092 if p, padLength, err = readByte(p); err != nil {
1093 countError("frame_headers_pad_short")
1094 return
1095 }
1096 }
1097 if fh.Flags.Has(FlagHeadersPriority) {
1098 var v uint32
1099 p, v, err = readUint32(p)
1100 if err != nil {
1101 countError("frame_headers_prio_short")
1102 return nil, err
1103 }
1104 hf.Priority.StreamDep = v & 0x7fffffff
1105 hf.Priority.Exclusive = (v != hf.Priority.StreamDep) // high bit was set
1106 p, hf.Priority.Weight, err = readByte(p)
1107 if err != nil {
1108 countError("frame_headers_prio_weight_short")
1109 return nil, err
1110 }
1111 }
1112 if len(p)-int(padLength) < 0 {
1113 countError("frame_headers_pad_too_big")
1114 return nil, streamError(fh.StreamID, ErrCodeProtocol)
1115 }
1116 hf.headerFragBuf = p[:len(p)-int(padLength)]
1117 return hf, nil
1118}
1119
1120// HeadersFrameParam are the parameters for writing a HEADERS frame.
1121type HeadersFrameParam struct {

Callers

nothing calls this directly

Calls 4

readByteFunction · 0.85
readUint32Function · 0.85
streamErrorFunction · 0.85
HasMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…