Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit81c9b19

Browse files
committed
Document compression API
So it begins :)
1 parent50dd426 commit81c9b19

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

‎handshake.go‎

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@ type AcceptOptions struct {
4545
// If you do, remember that if you store secure data in cookies, you wil need to verify the
4646
// Origin header yourself otherwise you are exposing yourself to a CSRF attack.
4747
InsecureSkipVerifybool
48+
49+
// Compression sets the WebSocket compression extension options.
50+
// If unset, CompressionNoContextTakeover is negotiated with
51+
// a threshold of 1024 bytes, flate.BestSpeed and only text messages
52+
// are compressed.
53+
Compression*CompressionOptions
4854
}
4955

5056
funcverifyClientRequest(w http.ResponseWriter,r*http.Request)error {
@@ -240,8 +246,42 @@ type DialOptions struct {
240246

241247
// Subprotocols lists the subprotocols to negotiate with the server.
242248
Subprotocols []string
249+
250+
// Compression sets the WebSocket compression extension options.
251+
// If unset, CompressionNoContextTakeover is negotiated with
252+
// a threshold of 1024 bytes, flate.BestSpeed and only text messages
253+
// are compressed.
254+
Compression*CompressionOptions
243255
}
244256

257+
typeCompressionOptionsstruct {
258+
// Type sets the WebSocket compression extension type.
259+
// Defaults to CompressionNoContextTakeover.
260+
TypeCompressionType
261+
262+
// Level controls the compression level negotiated.
263+
// Defaults to flate.BestSpeed.
264+
Levelint
265+
266+
// Threshold controls the minimum size in bytes of the message
267+
// before compression is enabled.
268+
// Defaults to 1024.
269+
Thresholdint
270+
271+
// Binary controls whether to compression binary messages.
272+
Binarybool
273+
274+
// Text controls whether to compress text messages.
275+
Textbool
276+
}
277+
278+
typeCompressionTypeint
279+
280+
const (
281+
CompressionNoContextTakeoverCompressionType=iota
282+
CompressionContextTakeover
283+
)
284+
245285
// Dial performs a WebSocket handshake on the given url with the given options.
246286
// The response is the WebSocket handshake response from the server.
247287
// If an error occurs, the returned response may be non nil. However, you can only

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp