Skip to content

Commit

Permalink
Remove x-webkit-deflate-frame dead code
Browse files Browse the repository at this point in the history
  • Loading branch information
abursavich committed Sep 9, 2020
1 parent f4997d7 commit 27d6747
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 53 deletions.
37 changes: 0 additions & 37 deletions accept.go
Expand Up @@ -240,9 +240,6 @@ func selectDeflate(extensions []websocketExtension, mode CompressionMode) (*comp
if copts, ok := acceptDeflate(ext, mode); ok {
return copts, true
}
// Disabled for now, see https://github.com/nhooyr/websocket/issues/218
// case "x-webkit-deflate-frame":
// return acceptWebkitDeflate(w, ext, mode)
}
}
return nil, false
Expand Down Expand Up @@ -271,40 +268,6 @@ func acceptDeflate(ext websocketExtension, mode CompressionMode) (*compressionOp
return copts, true
}

func acceptWebkitDeflate(w http.ResponseWriter, ext websocketExtension, mode CompressionMode) (*compressionOptions, error) {
copts := mode.opts()
// The peer must explicitly request it.
copts.serverNoContextTakeover = false

for _, p := range ext.params {
if p == "no_context_takeover" {
copts.serverNoContextTakeover = true
continue
}

// We explicitly fail on x-webkit-deflate-frame's max_window_bits parameter instead
// of ignoring it as the draft spec is unclear. It says the server can ignore it
// but the server has no way of signalling to the client it was ignored as the parameters
// are set one way.
// Thus us ignoring it would make the client think we understood it which would cause issues.
// See https://tools.ietf.org/html/draft-tyoshino-hybi-websocket-perframe-deflate-06#section-4.1
//
// Either way, we're only implementing this for webkit which never sends the max_window_bits
// parameter so we don't need to worry about it.
err := fmt.Errorf("unsupported x-webkit-deflate-frame parameter: %q", p)
http.Error(w, err.Error(), http.StatusBadRequest)
return nil, err
}

s := "x-webkit-deflate-frame"
if copts.clientNoContextTakeover {
s += "; no_context_takeover"
}
w.Header().Set("Sec-WebSocket-Extensions", s)

return copts, nil
}

func headerContainsToken(h http.Header, key, token string) bool {
token = strings.ToLower(token)

Expand Down
16 changes: 0 additions & 16 deletions accept_test.go
Expand Up @@ -396,22 +396,6 @@ func Test_selectDeflate(t *testing.T) {
},
expOK: true,
},
// {
// name: "x-webkit-deflate-frame",
// mode: CompressionNoContextTakeover,
// reqSecWebSocketExtensions: "x-webkit-deflate-frame; no_context_takeover",
// respSecWebSocketExtensions: "x-webkit-deflate-frame; no_context_takeover",
// expCopts: &compressionOptions{
// clientNoContextTakeover: true,
// serverNoContextTakeover: true,
// },
// },
// {
// name: "x-webkit-deflate/error",
// mode: CompressionNoContextTakeover,
// reqSecWebSocketExtensions: "x-webkit-deflate-frame; max_window_bits",
// error: true,
// },
}

for _, tc := range testCases {
Expand Down

0 comments on commit 27d6747

Please sign in to comment.