(fc *frameCache, fh FrameHeader, countError func(string), payload []byte)
| 653 | } |
| 654 | |
| 655 | func parseDataFrame(fc *frameCache, fh FrameHeader, countError func(string), payload []byte) (Frame, error) { |
| 656 | if fh.StreamID == 0 { |
| 657 | // DATA frames MUST be associated with a stream. If a |
| 658 | // DATA frame is received whose stream identifier |
| 659 | // field is 0x0, the recipient MUST respond with a |
| 660 | // connection error (Section 5.4.1) of type |
| 661 | // PROTOCOL_ERROR. |
| 662 | countError("frame_data_stream_0") |
| 663 | return nil, connError{ErrCodeProtocol, "DATA frame with stream ID 0"} |
| 664 | } |
| 665 | f := fc.getDataFrame() |
| 666 | f.FrameHeader = fh |
| 667 | |
| 668 | var padSize byte |
| 669 | if fh.Flags.Has(FlagDataPadded) { |
| 670 | var err error |
| 671 | payload, padSize, err = readByte(payload) |
| 672 | if err != nil { |
| 673 | countError("frame_data_pad_byte_short") |
| 674 | return nil, err |
| 675 | } |
| 676 | } |
| 677 | if int(padSize) > len(payload) { |
| 678 | // If the length of the padding is greater than the |
| 679 | // length of the frame payload, the recipient MUST |
| 680 | // treat this as a connection error. |
| 681 | // Filed: https://github.com/http2/http2-spec/issues/610 |
| 682 | countError("frame_data_pad_too_big") |
| 683 | return nil, connError{ErrCodeProtocol, "pad size larger than data payload"} |
| 684 | } |
| 685 | f.data = payload[:len(payload)-int(padSize)] |
| 686 | return f, nil |
| 687 | } |
| 688 | |
| 689 | var ( |
| 690 | errStreamID = errors.New("invalid stream ID") |
nothing calls this directly
no test coverage detected
searching dependent graphs…