WriteHeaders writes a single HEADERS frame. This is a low-level header writing method. Encoding headers and splitting them into any necessary CONTINUATION frames is handled elsewhere. It will perform exactly one Write to the underlying Writer. It is the caller's responsibility to not call other Wr
(p HeadersFrameParam)
| 1153 | // It will perform exactly one Write to the underlying Writer. |
| 1154 | // It is the caller's responsibility to not call other Write methods concurrently. |
| 1155 | func (h2f *Framer) WriteHeaders(p HeadersFrameParam) error { |
| 1156 | if !validStreamID(p.StreamID) && !h2f.AllowIllegalWrites { |
| 1157 | return errStreamID |
| 1158 | } |
| 1159 | var flags Flags |
| 1160 | if p.PadLength != 0 { |
| 1161 | flags |= FlagHeadersPadded |
| 1162 | } |
| 1163 | if p.EndStream { |
| 1164 | flags |= FlagHeadersEndStream |
| 1165 | } |
| 1166 | if p.EndHeaders { |
| 1167 | flags |= FlagHeadersEndHeaders |
| 1168 | } |
| 1169 | if !p.Priority.IsZero() { |
| 1170 | flags |= FlagHeadersPriority |
| 1171 | } |
| 1172 | h2f.startWrite(FrameHeaders, flags, p.StreamID) |
| 1173 | if p.PadLength != 0 { |
| 1174 | h2f.writeByte(p.PadLength) |
| 1175 | } |
| 1176 | if !p.Priority.IsZero() { |
| 1177 | v := p.Priority.StreamDep |
| 1178 | if !validStreamIDOrZero(v) && !h2f.AllowIllegalWrites { |
| 1179 | return errDepStreamID |
| 1180 | } |
| 1181 | if p.Priority.Exclusive { |
| 1182 | v |= 1 << 31 |
| 1183 | } |
| 1184 | h2f.writeUint32(v) |
| 1185 | h2f.writeByte(p.Priority.Weight) |
| 1186 | } |
| 1187 | h2f.wbuf = append(h2f.wbuf, p.BlockFragment...) |
| 1188 | h2f.wbuf = append(h2f.wbuf, padZeros[:p.PadLength]...) |
| 1189 | return h2f.endWrite() |
| 1190 | } |
| 1191 | |
| 1192 | // A PriorityFrame specifies the sender-advised priority of a stream. |
| 1193 | // See https://httpwg.org/specs/rfc7540.html#rfc.section.6.3 |
no test coverage detected