(copts *compressionOptions, h http.Header)
| 283 | } |
| 284 | |
| 285 | func verifyServerExtensions(copts *compressionOptions, h http.Header) (*compressionOptions, error) { |
| 286 | exts := websocketExtensions(h) |
| 287 | if len(exts) == 0 { |
| 288 | return nil, nil |
| 289 | } |
| 290 | |
| 291 | ext := exts[0] |
| 292 | if ext.name != "permessage-deflate" || len(exts) > 1 || copts == nil { |
| 293 | return nil, fmt.Errorf("WebSocket protcol violation: unsupported extensions from server: %+v", exts[1:]) |
| 294 | } |
| 295 | |
| 296 | _copts := *copts |
| 297 | copts = &_copts |
| 298 | |
| 299 | for _, p := range ext.params { |
| 300 | switch p { |
| 301 | case "client_no_context_takeover": |
| 302 | copts.clientNoContextTakeover = true |
| 303 | continue |
| 304 | case "server_no_context_takeover": |
| 305 | copts.serverNoContextTakeover = true |
| 306 | continue |
| 307 | } |
| 308 | if strings.HasPrefix(p, "server_max_window_bits=") { |
| 309 | // We can't adjust the deflate window, but decoding with a larger window is acceptable. |
| 310 | continue |
| 311 | } |
| 312 | |
| 313 | return nil, fmt.Errorf("unsupported permessage-deflate parameter: %q", p) |
| 314 | } |
| 315 | |
| 316 | return copts, nil |
| 317 | } |
| 318 | |
| 319 | var bufioReaderPool sync.Pool |
| 320 |
no test coverage detected
searching dependent graphs…