package http2
import (
)
type http2Config struct {
MaxConcurrentStreams uint32
MaxDecoderHeaderTableSize uint32
MaxEncoderHeaderTableSize uint32
MaxReadFrameSize uint32
MaxUploadBufferPerConnection int32
MaxUploadBufferPerStream int32
SendPingTimeout time.Duration
PingTimeout time.Duration
WriteByteTimeout time.Duration
PermitProhibitedCipherSuites bool
CountError func(errType string)
}
func ( *http.Server, *Server) http2Config {
:= http2Config{
MaxConcurrentStreams: .MaxConcurrentStreams,
MaxEncoderHeaderTableSize: .MaxEncoderHeaderTableSize,
MaxDecoderHeaderTableSize: .MaxDecoderHeaderTableSize,
MaxReadFrameSize: .MaxReadFrameSize,
MaxUploadBufferPerConnection: .MaxUploadBufferPerConnection,
MaxUploadBufferPerStream: .MaxUploadBufferPerStream,
SendPingTimeout: .ReadIdleTimeout,
PingTimeout: .PingTimeout,
WriteByteTimeout: .WriteByteTimeout,
PermitProhibitedCipherSuites: .PermitProhibitedCipherSuites,
CountError: .CountError,
}
fillNetHTTPServerConfig(&, )
setConfigDefaults(&, true)
return
}
func ( *Transport) http2Config {
:= http2Config{
MaxEncoderHeaderTableSize: .MaxEncoderHeaderTableSize,
MaxDecoderHeaderTableSize: .MaxDecoderHeaderTableSize,
MaxReadFrameSize: .MaxReadFrameSize,
SendPingTimeout: .ReadIdleTimeout,
PingTimeout: .PingTimeout,
WriteByteTimeout: .WriteByteTimeout,
}
if .MaxReadFrameSize < minMaxFrameSize {
.MaxReadFrameSize = minMaxFrameSize
} else if .MaxReadFrameSize > maxFrameSize {
.MaxReadFrameSize = maxFrameSize
}
if .t1 != nil {
fillNetHTTPTransportConfig(&, .t1)
}
setConfigDefaults(&, false)
return
}
func [ ~int | ~int32 | ~uint32 | ~int64]( *, , , ) {
if * < || * > {
* =
}
}
func ( *http2Config, bool) {
setDefault(&.MaxConcurrentStreams, 1, math.MaxUint32, defaultMaxStreams)
setDefault(&.MaxEncoderHeaderTableSize, 1, math.MaxUint32, initialHeaderTableSize)
setDefault(&.MaxDecoderHeaderTableSize, 1, math.MaxUint32, initialHeaderTableSize)
if {
setDefault(&.MaxUploadBufferPerConnection, initialWindowSize, math.MaxInt32, 1<<20)
} else {
setDefault(&.MaxUploadBufferPerConnection, initialWindowSize, math.MaxInt32, transportDefaultConnFlow)
}
if {
setDefault(&.MaxUploadBufferPerStream, 1, math.MaxInt32, 1<<20)
} else {
setDefault(&.MaxUploadBufferPerStream, 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 + *
}