@@ -245,11 +245,10 @@ func acceptCompression(r *http.Request, w http.ResponseWriter, mode CompressionM
245245
246246 for _ , ext := range websocketExtensions (r .Header ) {
247247 switch ext .name {
248+ // We used to implement x-webkit-deflate-fram too but Safari has bugs.
249+ // See https://github.com/nhooyr/websocket/issues/218
248250 case "permessage-deflate" :
249251 return acceptDeflate (w , ext , mode )
250- // Disabled for now, see https://github.com/nhooyr/websocket/issues/218
251- // case "x-webkit-deflate-frame":
252- // return acceptWebkitDeflate(w, ext, mode)
253252 }
254253 }
255254 return nil , nil
@@ -283,40 +282,6 @@ func acceptDeflate(w http.ResponseWriter, ext websocketExtension, mode Compressi
283282 return copts , nil
284283}
285284
286- func acceptWebkitDeflate (w http.ResponseWriter , ext websocketExtension , mode CompressionMode ) (* compressionOptions , error ) {
287- copts := mode .opts ()
288- // The peer must explicitly request it.
289- copts .serverNoContextTakeover = false
290-
291- for _ , p := range ext .params {
292- if p == "no_context_takeover" {
293- copts .serverNoContextTakeover = true
294- continue
295- }
296-
297- // We explicitly fail on x-webkit-deflate-frame's max_window_bits parameter instead
298- // of ignoring it as the draft spec is unclear. It says the server can ignore it
299- // but the server has no way of signalling to the client it was ignored as the parameters
300- // are set one way.
301- // Thus us ignoring it would make the client think we understood it which would cause issues.
302- // See https://tools.ietf.org/html/draft-tyoshino-hybi-websocket-perframe-deflate-06#section-4.1
303- //
304- // Either way, we're only implementing this for webkit which never sends the max_window_bits
305- // parameter so we don't need to worry about it.
306- err := fmt .Errorf ("unsupported x-webkit-deflate-frame parameter: %q" , p )
307- http .Error (w , err .Error (), http .StatusBadRequest )
308- return nil , err
309- }
310-
311- s := "x-webkit-deflate-frame"
312- if copts .clientNoContextTakeover {
313- s += "; no_context_takeover"
314- }
315- w .Header ().Set ("Sec-WebSocket-Extensions" , s )
316-
317- return copts , nil
318- }
319-
320285func headerContainsTokenIgnoreCase (h http.Header , key , token string ) bool {
321286 for _ , t := range headerTokens (h , key ) {
322287 if strings .EqualFold (t , token ) {
0 commit comments