good morning!!!!
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
W
websocket
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
open
websocket
Commits
e55ac181
Unverified
Commit
e55ac181
authored
5 years ago
by
Anmol Sethi
Browse files
Options
Downloads
Patches
Plain Diff
Document compression API
So it begins :)
parent
8604dee3
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
handshake.go
+48
-0
48 additions, 0 deletions
handshake.go
with
48 additions
and
0 deletions
handshake.go
+
48
−
0
View file @
e55ac181
...
...
@@ -45,6 +45,11 @@ type AcceptOptions struct {
// If you do, remember that if you store secure data in cookies, you wil need to verify the
// Origin header yourself otherwise you are exposing yourself to a CSRF attack.
InsecureSkipVerify
bool
// Compression sets the compression options.
// By default, compression is disabled.
// See docs on the CompressionOptions type.
Compression
*
CompressionOptions
}
func
verifyClientRequest
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
error
{
...
...
@@ -240,6 +245,49 @@ type DialOptions struct {
// Subprotocols lists the subprotocols to negotiate with the server.
Subprotocols
[]
string
// Compression sets the compression options.
// By default, compression is disabled.
// See docs on the CompressionOptions type.
Compression
CompressionOptions
}
// CompressionOptions describes the available compression options.
//
// See https://tools.ietf.org/html/rfc7692
//
// Enabling compression may spike memory usage as each flate.Writer takes up 1.2 MB.
// See https://github.com/gorilla/websocket/issues/203
// Benchmark before enabling in production.
//
// This API is experimental and subject to change.
type
CompressionOptions
struct
{
// ContextTakeover controls whether context takeover is enabled.
//
// If ContextTakeover == false, then a flate.Writer will be grabbed
// from the pool as needed for every message written to the connection.
//
// If ContextTakeover == true, then a flate.Writer will be allocated for each connection.
// This allows more efficient compression as the sliding window from previous
// messages will be used instead of resetting in between every message.
// The downside is that for every connection there will be a fixed allocation
// for the flate.Writer.
//
// See https://www.igvita.com/2013/11/27/configuring-and-optimizing-websocket-compression.
ContextTakeover
bool
// Level controls the compression level negotiated.
// Defaults to flate.BestSpeed.
Level
int
// Threshold controls the minimum message size in bytes before compression is used.
// In the case of ContextTakeover == false, a flate.Writer will not be grabbed
// from the pool until the message exceeds this threshold.
//
// Must not be greater than 4096 as that is the write buffer's size.
//
// Defaults to 512.
Threshold
int
}
// Dial performs a WebSocket handshake on the given url with the given options.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment