(_ *frameCache, fh FrameHeader, countError func(string), p []byte)
| 772 | } |
| 773 | |
| 774 | func parseSettingsFrame(_ *frameCache, fh FrameHeader, countError func(string), p []byte) (Frame, error) { |
| 775 | if fh.Flags.Has(FlagSettingsAck) && fh.Length > 0 { |
| 776 | // When this (ACK 0x1) bit is set, the payload of the |
| 777 | // SETTINGS frame MUST be empty. Receipt of a |
| 778 | // SETTINGS frame with the ACK flag set and a length |
| 779 | // field value other than 0 MUST be treated as a |
| 780 | // connection error (Section 5.4.1) of type |
| 781 | // FRAME_SIZE_ERROR. |
| 782 | countError("frame_settings_ack_with_length") |
| 783 | return nil, ConnectionError(ErrCodeFrameSize) |
| 784 | } |
| 785 | if fh.StreamID != 0 { |
| 786 | // SETTINGS frames always apply to a connection, |
| 787 | // never a single stream. The stream identifier for a |
| 788 | // SETTINGS frame MUST be zero (0x0). If an endpoint |
| 789 | // receives a SETTINGS frame whose stream identifier |
| 790 | // field is anything other than 0x0, the endpoint MUST |
| 791 | // respond with a connection error (Section 5.4.1) of |
| 792 | // type PROTOCOL_ERROR. |
| 793 | countError("frame_settings_has_stream") |
| 794 | return nil, ConnectionError(ErrCodeProtocol) |
| 795 | } |
| 796 | if len(p)%6 != 0 { |
| 797 | countError("frame_settings_mod_6") |
| 798 | // Expecting even number of 6 byte settings. |
| 799 | return nil, ConnectionError(ErrCodeFrameSize) |
| 800 | } |
| 801 | f := &SettingsFrame{FrameHeader: fh, p: p} |
| 802 | if v, ok := f.Value(http2.SettingInitialWindowSize); ok && v > (1<<31)-1 { |
| 803 | countError("frame_settings_window_size_too_big") |
| 804 | // Values above the maximum flow control window size of 2^31 - 1 MUST |
| 805 | // be treated as a connection error (Section 5.4.1) of type |
| 806 | // FLOW_CONTROL_ERROR. |
| 807 | return nil, ConnectionError(ErrCodeFlowControl) |
| 808 | } |
| 809 | return f, nil |
| 810 | } |
| 811 | |
| 812 | func (f *SettingsFrame) IsAck() bool { |
| 813 | return f.FrameHeader.Flags.Has(FlagSettingsAck) |
nothing calls this directly
no test coverage detected
searching dependent graphs…