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

Rewrite with compression support#163

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
nhooyr merged 56 commits intomasterfromcompress
Feb 16, 2020
Merged
Show file tree
Hide file tree
Changes from1 commit
Commits
Show all changes
56 commits
Select commitHold shift + click to select a range
8604dee
Increase TestWASM timeout
nhooyrOct 15, 2019
e55ac18
Document compression API
nhooyrOct 14, 2019
e142e08
Improve compression docs
nhooyrNov 12, 2019
53c1aea
Implement compression extension negotiation
nhooyrNov 12, 2019
2cf6c28
Implement compression writer and reader pooling
nhooyrNov 12, 2019
a01afea
Support x-webkit-deflate-frame extension for Safari
nhooyrNov 12, 2019
531d4fa
Improve general compression API and write docs
nhooyrNov 12, 2019
d0a8049
Rewrite core
nhooyrNov 19, 2019
dd107dd
Update CI
nhooyrNov 28, 2019
6c6b8e9
Cleanup wspb and wsjson
nhooyrNov 28, 2019
6b782a3
Run make fmt
nhooyrNov 28, 2019
989ba2f
Change websocket to WebSocket in docs/errors
nhooyrNov 28, 2019
9f15963
Simplify dial.go
nhooyrNov 28, 2019
120911b
Remove use of math/rand.Init
nhooyrNov 28, 2019
7ad1514
Update README.md comparison
nhooyrNov 29, 2019
746140b
Further improve README
nhooyrNov 29, 2019
43cb01e
Refactor read.go/write.go
nhooyrNov 29, 2019
e8dfe27
Make CI pass
nhooyrNov 29, 2019
f6137f3
Add minor improvements
nhooyrDec 6, 2019
6f6fa43
Refactor autobahn
nhooyrDec 31, 2019
8c87970
Add slidingWindowReader
nhooyrJan 4, 2020
aaf4b45
Up test coverage of accept.go to 100%
nhooyrJan 26, 2020
6b76536
Up dial coverage to 100%
nhooyrJan 30, 2020
0f115ed
Add Go 1.12 support
nhooyrJan 31, 2020
b6b56b7
Both modes seem to work :)
nhooyrFeb 5, 2020
9e32354
Fix randString method in tests
nhooyrFeb 6, 2020
78da35e
Get test with multiple messages working
nhooyrFeb 7, 2020
d092686
Autobahn tests fully pass :)
nhooyrFeb 8, 2020
6975801
Fix race in tests
nhooyrFeb 9, 2020
bbaf469
Fix test step
nhooyrFeb 9, 2020
faadcc9
Simplify tests
nhooyrFeb 9, 2020
3f2589f
Remove quite a bit of slog
nhooyrFeb 9, 2020
b53f306
Get Wasm tests working
nhooyrFeb 9, 2020
69ff675
More tests and fixes
nhooyrFeb 9, 2020
085e671
Get coverage to 85%
nhooyrFeb 9, 2020
51769b3
Add wspb test
nhooyrFeb 9, 2020
670be05
Merge in handshake improvements from master
nhooyrFeb 9, 2020
988b8f2
Merge remote-tracking branch 'origin/master' into compress
nhooyrFeb 9, 2020
3a526d8
Fix bug in closeHandshake
nhooyrFeb 9, 2020
999b812
Fix race in msgReader
nhooyrFeb 9, 2020
4b84d25
Fix a race with c.closed
nhooyrFeb 9, 2020
85f249d
Up timeouts
nhooyrFeb 9, 2020
6b38ebb
Test fixes
nhooyrFeb 9, 2020
6770421
Fix goroutine leak from deadlock when closing
nhooyrFeb 12, 2020
c752365
Make flateThreshold work
nhooyrFeb 12, 2020
0ea9466
Cleanup writeMu and flateThreshold
nhooyrFeb 12, 2020
b33d48c
Minor cleanup
nhooyrFeb 12, 2020
9c5bfab
Simplifications of conn_test.go
nhooyrFeb 13, 2020
3673c2c
Use basic test assertions
nhooyrFeb 13, 2020
c5b0a00
Fix badPing test duration
nhooyrFeb 13, 2020
1c7c14e
Pool sliding windows
nhooyrFeb 13, 2020
503b469
Simplify sliding window API
nhooyrFeb 13, 2020
dff4af3
Add conn benchmark
nhooyrFeb 13, 2020
2377cca
Switch to klauspost/compress
nhooyrFeb 15, 2020
d57b253
Report how efficient compression is in BenchmarkConn
nhooyrFeb 16, 2020
1bc100d
Update docs and random little issues
nhooyrFeb 16, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
PrevPrevious commit
NextNext commit
Improve compression docs
  • Loading branch information
@nhooyr
nhooyr committedNov 29, 2019
commite142e08cbe82354cbee73f4b023623f04a55924d
8 changes: 4 additions & 4 deletionsREADME.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
# websocket

[![GitHub Release](https://img.shields.io/github/v/release/nhooyr/websocket?color=6b9ded&sort=semver)](https://github.com/nhooyr/websocket/releases)
[![GoDoc](https://godoc.org/nhooyr.io/websocket?status.svg)](https://godoc.org/nhooyr.io/websocket)
[![Coveralls](https://img.shields.io/coveralls/github/nhooyr/websocket?color=65d6a4)](https://coveralls.io/github/nhooyr/websocket)
[![CI Status](https://github.com/nhooyr/websocket/workflows/ci/badge.svg)](https://github.com/nhooyr/websocket/actions)
[![version](https://img.shields.io/github/v/release/nhooyr/websocket?color=6b9ded&sort=semver)](https://github.com/nhooyr/websocket/releases)
[![docs](https://godoc.org/nhooyr.io/websocket?status.svg)](https://godoc.org/nhooyr.io/websocket)
[![coverage](https://img.shields.io/coveralls/github/nhooyr/websocket?color=65d6a4)](https://coveralls.io/github/nhooyr/websocket)
[![ci](https://github.com/nhooyr/websocket/workflows/ci/badge.svg)](https://github.com/nhooyr/websocket/actions)

websocket is a minimal and idiomatic WebSocket library for Go.

Expand Down
44 changes: 29 additions & 15 deletionshandshake.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -249,34 +249,45 @@ type DialOptions struct {
// Compression sets the compression options.
// By default, compression is disabled.
// See docs on the CompressionOptions type.
Compression CompressionOptions
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.
// The NoContextTakeover variables control whether a flate.Writer or flate.Reader is allocated
// for every connection (context takeover) versus shared from a pool (no context takeover).
//
// The advantage to context takeover is more efficient compression as the sliding window from previous
// messages will be used instead of being reset between every message.
//
// The advantage to no context takeover is that the flate structures are allocated as needed
// and shared between connections instead of giving each connection a fixed flate.Writer and
// flate.Reader.
//
// See https://www.igvita.com/2013/11/27/configuring-and-optimizing-websocket-compression.
//
// Enabling compression will increase memory and CPU usage.
// Thus it is not ideal for every use case and disabled by default.
// See https://github.com/gorilla/websocket/issues/203
//Benchmark before enabling in production.
//Profile 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.
// ServerNoContextTakeover controls whether the server should use context takeover.
// See docs on CompressionOptions for discussion regarding context takeover.
//
// IfContextTakeover == 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
// forthe flate.Writer.
// Ifset by the client, will guarantee that the server does not use context takeover.
ServerNoContextTakeover bool

//ClientNoContextTakeover controls whether the client should use context takeover.
//See docs on CompressionOptionsfordiscussion regarding context takeover.
//
//See https://www.igvita.com/2013/11/27/configuring-and-optimizing-websocket-compression.
ContextTakeover bool
//If set by the server, will guarantee that the client does not use context takeover.
ClientNoContextTakeover bool

// Level controls the compression levelnegotiated.
// Level controls the compression levelused.
// Defaults to flate.BestSpeed.
Level int

Expand DownExpand Up@@ -355,6 +366,9 @@ func dial(ctx context.Context, u string, opts *DialOptions) (_ *Conn, _ *http.Re
if len(opts.Subprotocols) > 0 {
req.Header.Set("Sec-WebSocket-Protocol", strings.Join(opts.Subprotocols, ","))
}
if opts.Compression != nil {
req.Header.Set("Sec-WebSocket-Extensions", "permessage-deflate; server_no_context_takeover; client_no_context_takeover")
}

resp, err := opts.HTTPClient.Do(req)
if err != nil {
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp