http2: fix enforcement of max header list size
In the first attempt to enforce the SETTINGS_MAX_HEADER_LIST_SIZE (https://go-review.googlesource.com/15751), the enforcement happened in the hpack decoder and the hpack decoder returned errors on Write and Close if the limit was violated. This was incorrect because the decoder is used over the life of the connection and all subsequent requests and could therefore get out of sync. Instead, this moves the counting of the limit up to the http2 package in the serverConn type, and replaces the hpack counting mechanism with a simple on/off switch. When SetEmitEnabled is set false, the header field emit callbacks will be suppressed and the hpack Decoder will do less work (less CPU and garbage) if possible, but will still return nil from Write and Close on valid input, and will still stay in sync it the stream. The http2 Server then returns a 431 error if emits were disabled while processing the HEADER or any CONTINUATION frames. Fixes golang/go#12843 Change-Id: I3b41aaefc6c6ee6218225f8dc62bba6ae5fe8f2d Reviewed-on: https://go-review.googlesource.com/15733Reviewed-by: Andrew Gerrand <adg@golang.org>
Showing
Please
register
or
sign in
to comment