(_ *frameCache, fh FrameHeader, countError func(string), p []byte)
| 1076 | } |
| 1077 | |
| 1078 | func 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. |
| 1121 | type HeadersFrameParam struct { |
nothing calls this directly
no test coverage detected
searching dependent graphs…