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

Method WritePushPromise

internal/http2/frame.go:1400–1422  ·  view source on GitHub ↗

WritePushPromise writes a single PushPromise Frame. As with Header Frames, This is the low level call for writing individual frames. Continuation frames are handled elsewhere. It will perform exactly one Write to the underlying Writer. It is the caller's responsibility to not call other Write meth

(p PushPromiseParam)

Source from the content-addressed store, hash-verified

1398// It will perform exactly one Write to the underlying Writer.
1399// It is the caller's responsibility to not call other Write methods concurrently.
1400func (h2f *Framer) WritePushPromise(p PushPromiseParam) error {
1401 if !validStreamID(p.StreamID) && !h2f.AllowIllegalWrites {
1402 return errStreamID
1403 }
1404 var flags Flags
1405 if p.PadLength != 0 {
1406 flags |= FlagPushPromisePadded
1407 }
1408 if p.EndHeaders {
1409 flags |= FlagPushPromiseEndHeaders
1410 }
1411 h2f.startWrite(FramePushPromise, flags, p.StreamID)
1412 if p.PadLength != 0 {
1413 h2f.writeByte(p.PadLength)
1414 }
1415 if !validStreamID(p.PromiseID) && !h2f.AllowIllegalWrites {
1416 return errStreamID
1417 }
1418 h2f.writeUint32(p.PromiseID)
1419 h2f.wbuf = append(h2f.wbuf, p.BlockFragment...)
1420 h2f.wbuf = append(h2f.wbuf, padZeros[:p.PadLength]...)
1421 return h2f.endWrite()
1422}
1423
1424// WriteRawFrame writes a raw frame. This can be used to write
1425// extension frames unknown to this package.

Callers

nothing calls this directly

Calls 5

startWriteMethod · 0.95
writeByteMethod · 0.95
writeUint32Method · 0.95
endWriteMethod · 0.95
validStreamIDFunction · 0.85

Tested by

no test coverage detected