package http2
import (
)
type Config struct {
MaxConcurrentStreams int
StrictMaxConcurrentRequests bool
MaxDecoderHeaderTableSize int
MaxEncoderHeaderTableSize int
MaxReadFrameSize int
MaxReceiveBufferPerConnection int
MaxReceiveBufferPerStream int
SendPingTimeout time.Duration
PingTimeout time.Duration
WriteByteTimeout time.Duration
PermitProhibitedCipherSuites bool
CountError func(errType string)
}
func ( ServerConfig) Config {
:= Config{}
fillNetHTTPConfig(&, .HTTP2Config())
setConfigDefaults(&, true)
return
}
func ( *Transport) Config {
:= Config{}
if .t1 != nil {
fillNetHTTPConfig(&, .t1.HTTP2Config())
}
setConfigDefaults(&, false)
return
}
func [ ~int | ~int32 | ~uint32 | ~int64]( *, , , ) {
if * < || * > {
* =
}
}
func ( *Config, bool) {
setDefault(&.MaxConcurrentStreams, 1, math.MaxInt32, defaultMaxStreams)
setDefault(&.MaxEncoderHeaderTableSize, 1, math.MaxInt32, initialHeaderTableSize)
setDefault(&.MaxDecoderHeaderTableSize, 1, math.MaxInt32, initialHeaderTableSize)
if {
setDefault(&.MaxReceiveBufferPerConnection, initialWindowSize, math.MaxInt32, 1<<20)
} else {
setDefault(&.MaxReceiveBufferPerConnection, initialWindowSize, math.MaxInt32, transportDefaultConnFlow)
}
if {
setDefault(&.MaxReceiveBufferPerStream, 1, math.MaxInt32, 1<<20)
} else {
setDefault(&.MaxReceiveBufferPerStream, 1, math.MaxInt32, transportDefaultStreamFlow)
}
setDefault(&.MaxReadFrameSize, minMaxFrameSize, maxFrameSize, defaultMaxReadFrameSize)
setDefault(&.PingTimeout, 1, math.MaxInt64, 15*time.Second)
}
func ( int64) int64 {
const = 32
const = 10
return + *
}
func ( *Config, Config) {
if .MaxConcurrentStreams != 0 {
.MaxConcurrentStreams = .MaxConcurrentStreams
}
if .StrictMaxConcurrentRequests {
.StrictMaxConcurrentRequests = true
}
if .MaxEncoderHeaderTableSize != 0 {
.MaxEncoderHeaderTableSize = .MaxEncoderHeaderTableSize
}
if .MaxDecoderHeaderTableSize != 0 {
.MaxDecoderHeaderTableSize = .MaxDecoderHeaderTableSize
}
if .MaxConcurrentStreams != 0 {
.MaxConcurrentStreams = .MaxConcurrentStreams
}
if .MaxReadFrameSize != 0 {
.MaxReadFrameSize = .MaxReadFrameSize
}
if .MaxReceiveBufferPerConnection != 0 {
.MaxReceiveBufferPerConnection = .MaxReceiveBufferPerConnection
}
if .MaxReceiveBufferPerStream != 0 {
.MaxReceiveBufferPerStream = .MaxReceiveBufferPerStream
}
if .SendPingTimeout != 0 {
.SendPingTimeout = .SendPingTimeout
}
if .PingTimeout != 0 {
.PingTimeout = .PingTimeout
}
if .WriteByteTimeout != 0 {
.WriteByteTimeout = .WriteByteTimeout
}
if .PermitProhibitedCipherSuites {
.PermitProhibitedCipherSuites = true
}
if .CountError != nil {
.CountError = .CountError
}
}