Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update on custom HTTP2 SETTINGS #1

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 42 additions & 8 deletions h2_bundle.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

65 changes: 45 additions & 20 deletions transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -295,23 +295,14 @@ type Transport struct {

hasCustomInitialSettings bool

// MaxHeaderListSize is the http2 SETTINGS_MAX_HEADER_LIST_SIZE to
// send in the initial settings frame. It is how many bytes
// of response headers are allowed. Unlike the http2 spec, zero here
// means to use a default limit (currently 10MB). If you actually
// want to advertise an unlimited value to the peer, Transport
// interprets the highest possible value here (0xffffffff or 1<<32-1)
// to mean no limit.
MaxHeaderListSize uint32
// SETTINGS Frame
hasCustomHeaderTableSize bool
hasCustomEnablePush bool
hasCustomInitialWindowSize bool
hasCustomMaxConcurrentStreams bool
hasCustomMaxFrameSize bool
hasCustomMaxHeaderListSize bool

// MaxReadFrameSize is the http2 SETTINGS_MAX_FRAME_SIZE to send in the
// initial settings frame. It is the size in bytes of the largest frame
// payload that the sender is willing to receive. If 0, no setting is
// sent, and the value is provided by the peer, which should be 16384
// according to the spec:
// https://datatracker.ietf.org/doc/html/rfc7540#section-6.5.2.
// Values are bounded in the range 16k to 16M.
MaxFrameSize uint32

// MaxDecoderHeaderTableSize optionally specifies the http2
// SETTINGS_HEADER_TABLE_SIZE to send in the initial settings frame. It
Expand All @@ -320,17 +311,44 @@ type Transport struct {
// of 4096 is used.
HeaderTableSize uint32


// MaxDecoderHeaderTableSize optionally specifies the http2
// SETTINGS_ENABLE_PUSH to send in the initial settings frame.
EnablePush uint32

// MaxDecoderHeaderTableSize optionally specifies the http2
// SETTINGS_MAX_CONCURRENT_STREAMS to send in the initial settings frame.
MaxConcurrentStreams uint32

// MaxDecoderHeaderTableSize optionally specifies the http2
// SETTINGS_INITIAL_WINDOW_SIZE to send in the initial settings frame.
InitialWindowSize uint32


// MaxDecoderHeaderTableSize optionally specifies the http2
// SETTINGS_MAX_CONCURRENT_STREAMS to send in the initial settings frame.
MaxConcurrentStreams uint32


// MaxReadFrameSize is the http2 SETTINGS_MAX_FRAME_SIZE to send in the
// initial settings frame. It is the size in bytes of the largest frame
// payload that the sender is willing to receive. If 0, no setting is
// sent, and the value is provided by the peer, which should be 16384
// according to the spec:
// https://datatracker.ietf.org/doc/html/rfc7540#section-6.5.2.
// Values are bounded in the range 16k to 16M.
MaxFrameSize uint32


// MaxHeaderListSize is the http2 SETTINGS_MAX_HEADER_LIST_SIZE to
// send in the initial settings frame. It is how many bytes
// of response headers are allowed. Unlike the http2 spec, zero here
// means to use a default limit (currently 10MB). If you actually
// want to advertise an unlimited value to the peer, Transport
// interprets the highest possible value here (0xffffffff or 1<<32-1)
// to mean no limit.
MaxHeaderListSize uint32


// WINDOW_UPDATE Frame
WindowSizeIncrement uint32
}

// A cancelKey is the key of the reqCanceler map.
Expand All @@ -340,8 +358,15 @@ type cancelKey struct {
req *Request
}

func (t *Transport) EnableCustomInitialSettings() {
func (t *Transport) EnableCustomInitialSettings(ts bool, ep bool, ws bool, cs bool, fs bool, hs bool, iv uint32) {
t.hasCustomInitialSettings = true
t.hasCustomHeaderTableSize = ts
t.hasCustomEnablePush = ep
t.hasCustomInitialWindowSize = ws
t.hasCustomMaxConcurrentStreams = cs
t.hasCustomMaxFrameSize = fs
t.hasCustomMaxHeaderListSize = hs
t.WindowSizeIncrement = iv
}

func (t *Transport) writeBufferSize() int {
Expand Down