update sd

This commit is contained in:
ginuerzh
2023-11-02 20:52:33 +08:00
parent a7166b8206
commit 68edeb2d59
11 changed files with 126 additions and 173 deletions

View File

@ -31,33 +31,21 @@ type metadata struct {
}
func (l *mwsListener) parseMetadata(md mdata.Metadata) (err error) {
const (
path = "path"
backlog = "backlog"
header = "header"
handshakeTimeout = "handshakeTimeout"
readHeaderTimeout = "readHeaderTimeout"
readBufferSize = "readBufferSize"
writeBufferSize = "writeBufferSize"
enableCompression = "enableCompression"
)
l.md.path = mdutil.GetString(md, path)
l.md.path = mdutil.GetString(md, "ws.path", "path")
if l.md.path == "" {
l.md.path = defaultPath
}
l.md.backlog = mdutil.GetInt(md, backlog)
l.md.backlog = mdutil.GetInt(md, "ws.backlog", "backlog")
if l.md.backlog <= 0 {
l.md.backlog = defaultBacklog
}
l.md.handshakeTimeout = mdutil.GetDuration(md, handshakeTimeout)
l.md.readHeaderTimeout = mdutil.GetDuration(md, readHeaderTimeout)
l.md.readBufferSize = mdutil.GetInt(md, readBufferSize)
l.md.writeBufferSize = mdutil.GetInt(md, writeBufferSize)
l.md.enableCompression = mdutil.GetBool(md, enableCompression)
l.md.handshakeTimeout = mdutil.GetDuration(md, "ws.handshakeTimeout", "handshakeTimeout")
l.md.readHeaderTimeout = mdutil.GetDuration(md, "ws.readHeaderTimeout", "readHeaderTimeout")
l.md.readBufferSize = mdutil.GetInt(md, "ws.readBufferSize", "readBufferSize")
l.md.writeBufferSize = mdutil.GetInt(md, "ws.writeBufferSize", "writeBufferSize")
l.md.enableCompression = mdutil.GetBool(md, "ws.enableCompression", "enableCompression")
l.md.muxCfg = &mux.Config{
Version: mdutil.GetInt(md, "mux.version"),
@ -69,7 +57,7 @@ func (l *mwsListener) parseMetadata(md mdata.Metadata) (err error) {
MaxStreamBuffer: mdutil.GetInt(md, "mux.maxStreamBuffer"),
}
if mm := mdutil.GetStringMapString(md, header); len(mm) > 0 {
if mm := mdutil.GetStringMapString(md, "ws.header", "header"); len(mm) > 0 {
hd := http.Header{}
for k, v := range mm {
hd.Add(k, v)