Skip to content

Commit

Permalink
更新
Browse files Browse the repository at this point in the history
  • Loading branch information
guonaihong committed May 18, 2024
1 parent 122fb7e commit da4c929
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions deflate/permessage_deflate_conf.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package deflate
import (
"net/http"
"strconv"
"strings"
)

// https://datatracker.ietf.org/doc/html/rfc7692#section-7.1
Expand Down Expand Up @@ -114,3 +115,24 @@ func parsePermessageDeflate(header http.Header) (pmd PermessageDeflateConf, err
func GetConnPermessageDeflate(header http.Header) (pd PermessageDeflateConf, err error) {
return parsePermessageDeflate(header)
}

func GenSecWebSocketExtensions(pd PermessageDeflateConf) string {
ext := make([]string, 1, 5)
ext[0] = "permessage-deflate"
if !pd.ClientContextTakeover {
ext = append(ext, "client_no_context_takeover")
}

if !pd.ServerContextTakeover {
ext = append(ext, "server_no_context_takeover")
}

if pd.ClientMaxWindowBits != 0 {
ext = append(ext, "client_max_window_bits="+strconv.Itoa(int(pd.ClientMaxWindowBits)))
}

if pd.ServerMaxWindowBits != 0 {
ext = append(ext, "server_max_window_bits="+strconv.Itoa(int(pd.ServerMaxWindowBits)))
}
return strings.Join(ext, "; ")
}

0 comments on commit da4c929

Please sign in to comment.