(_ *frameCache, fh FrameHeader, countError func(string), p []byte)
| 1329 | } |
| 1330 | |
| 1331 | func parsePushPromise(_ *frameCache, fh FrameHeader, countError func(string), p []byte) (_ Frame, err error) { |
| 1332 | pp := &PushPromiseFrame{ |
| 1333 | FrameHeader: fh, |
| 1334 | } |
| 1335 | if pp.StreamID == 0 { |
| 1336 | // PUSH_PROMISE frames MUST be associated with an existing, |
| 1337 | // peer-initiated stream. The stream identifier of a |
| 1338 | // PUSH_PROMISE frame indicates the stream it is associated |
| 1339 | // with. If the stream identifier field specifies the value |
| 1340 | // 0x0, a recipient MUST respond with a connection error |
| 1341 | // (Section 5.4.1) of type PROTOCOL_ERROR. |
| 1342 | countError("frame_pushpromise_zero_stream") |
| 1343 | return nil, ConnectionError(ErrCodeProtocol) |
| 1344 | } |
| 1345 | // The PUSH_PROMISE frame includes optional padding. |
| 1346 | // Padding fields and flags are identical to those defined for DATA frames |
| 1347 | var padLength uint8 |
| 1348 | if fh.Flags.Has(FlagPushPromisePadded) { |
| 1349 | if p, padLength, err = readByte(p); err != nil { |
| 1350 | countError("frame_pushpromise_pad_short") |
| 1351 | return |
| 1352 | } |
| 1353 | } |
| 1354 | |
| 1355 | p, pp.PromiseID, err = readUint32(p) |
| 1356 | if err != nil { |
| 1357 | countError("frame_pushpromise_promiseid_short") |
| 1358 | return |
| 1359 | } |
| 1360 | pp.PromiseID = pp.PromiseID & (1<<31 - 1) |
| 1361 | |
| 1362 | if int(padLength) > len(p) { |
| 1363 | // like the DATA frame, error out if padding is longer than the body. |
| 1364 | countError("frame_pushpromise_pad_too_big") |
| 1365 | return nil, ConnectionError(ErrCodeProtocol) |
| 1366 | } |
| 1367 | pp.headerFragBuf = p[:len(p)-int(padLength)] |
| 1368 | return pp, nil |
| 1369 | } |
| 1370 | |
| 1371 | // PushPromiseParam are the parameters for writing a PUSH_PROMISE frame. |
| 1372 | type PushPromiseParam struct { |
nothing calls this directly
no test coverage detected
searching dependent graphs…