Documentation
¶
Overview ¶
Copyright 2021-2024 antlabs. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2021-2024 antlabs. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright 2021-2024 antlabs. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
Constants ¶
const (
DefaultCompressionLevel = 1
)
Variables ¶
var ( ErrUnexpectedFlateStream = errors.New("internal error, unexpected bytes at end of flate stream") ErrWriteClosed = errors.New("write close") )
Functions ¶
func GenSecWebSocketExtensions ¶
func GenSecWebSocketExtensions(pd PermessageDeflateConf) string
Types ¶
type CompressContextTakeover ¶
type CompressContextTakeover struct {
// contains filtered or unexported fields
}
func NewCompressContextTakeover ¶
func NewCompressContextTakeover(bit uint8) (en *CompressContextTakeover, err error)
type DeCompressContextTakeover ¶
type DeCompressContextTakeover struct {
// contains filtered or unexported fields
}
上下文-解压缩
func NewDecompressContextTakeover ¶
func NewDecompressContextTakeover(bit uint8) (*DeCompressContextTakeover, error)
初始化一个对象
func (*DeCompressContextTakeover) Decompress ¶
func (d *DeCompressContextTakeover) Decompress(payload *[]byte, maxMessage int64) (outBytes2 *[]byte, err error)
解压缩 d有值时,上下文接管的情况调用 d为nil时, 上下文不接管的情况下调用,利用了go,对象为空,调用函数不会panic的特性
type PermessageDeflateConf ¶
type PermessageDeflateConf struct { // 是否启用,压缩或者解压缩 Enable bool // 解压缩 Decompression bool // 压缩 Compression bool // 服务端是否支持上下文接管 // https://datatracker.ietf.org/doc/html/rfc7692#section-7.1.1.1 // 客户端可以发送 server_no_context_takeover 参数,表示服务端不需要上下文接管 ServerContextTakeover bool // 客户端是否支持上下文接管 // https://datatracker.ietf.org/doc/html/rfc7692#section-7.1.1.2 // 客户端发关 client_no_context_takeover 参数,表示客户端不使用上下文接管 // 即使服务端没有响应 client_no_context_takeover 参数,客户端也不会使用上下文接管 ClientContextTakeover bool // 客户端最大窗口位数, N=8-15, 窗口的大小2^N ClientMaxWindowBits uint8 // 服务端最大窗口位数, N=8-15, 窗口的大小2^N ServerMaxWindowBits uint8 }
https://datatracker.ietf.org/doc/html/rfc7692#section-7.1
func GetConnPermessageDeflate ¶
func GetConnPermessageDeflate(header http.Header) (pd PermessageDeflateConf, err error)
是否打开解压缩