Commit Graph

200 Commits

Author SHA1 Message Date
Gary Burd 0674c7c796 Improve upgrade error messages
Upgrade typically fails because the request is not a handshake, not
because the handshake is malformed. To help developers diagnose the
common case, state explicitly that the request is not a handshake in
error messages.

To help diagnose malformed requests, capitalize and 'quote' header names
in error messages.
2017-01-23 10:55:51 -08:00
Gary Burd 2257eda00b Fix compile error on Go < 1.6 2017-01-19 11:27:08 -08:00
Gary Burd 522f286a67 Fix to compile on Go < 1.6 2017-01-19 11:23:28 -08:00
Gary Burd b0dc45572b Change default and add API for compression level
Change the default compression level to 1. This level is faster and uses
less memory.

Add Conn.SetCompressionLevel API to allow applications to tune
compression on a per message basis.
2017-01-19 11:00:23 -08:00
Gary Burd bb547c6c5c Improve SetXHandler documentation 2017-01-15 13:09:21 -08:00
Gary Burd 561ac01ecf Merge pull request #205 from FZambia/compression_benchmarks
benchmarks for write with compression enabled/disabled
2017-01-13 20:07:17 -08:00
Alexandr Emelin 34e053563d benchmarks for write with compression enabled/disabled 2017-01-13 12:06:51 +03:00
Gary Burd 17634340a8 Update compression documentation
Add "EXPERIMENTAL" to the compress section header.  This change is intended to draw more attention to the status of the feature as stated in the first sentence of the section.  This is not a change in the status.
2017-01-11 11:29:28 -08:00
Gary Burd adf16b3178 Add safe maskBytes
Fixes #200.
2016-12-31 20:13:41 -08:00
Gary Burd 5ddbd28fbd Merge branch 'compress' 2016-12-27 17:08:04 -05:00
Gary Burd 6c51b25bc8 Compression improvements
- Remove unnecessary error return from compressNoContextTakeover.
- Simplify use of sync.Pool.
- Fix formatting in compression documentation.
2016-12-27 17:05:16 -05:00
Gary Burd 404e6b135d Merge pull request #199 from AndrienkoAleksandr/master
Fix up README.md for command example.
2016-12-27 09:27:37 -05:00
Aleksandr Andrienko 0e7877a5a1 Fix up README.md for command example. 2016-12-27 15:04:14 +02:00
Cyrus Katrak 2db2f66488 pool flate readers 2016-12-19 07:28:05 -08:00
Cyrus Katrak 3ab3a8b883 pool flate writers 2016-12-16 15:41:18 -08:00
Gary Burd 0868951cdb Improve WriteMessage fast path
Restructure to avoid messageWriter allocation.
2016-12-07 16:21:58 -08:00
Gary Burd e8f0f8aaa9 Merge pull request #185 from shivamMg/doc-fix
Fix documentation
2016-11-12 06:27:12 -08:00
Shivam Mamgain dc13401989 Fix documentation
Specify correct function name in README
2016-11-12 16:02:12 +05:30
Gary Burd 9fbf129ff2 Add Conn.[Set]CloseHandler 2016-11-02 13:04:59 -07:00
Gary Burd 80a0029a65 Improve write error handling
- Do not fail NextWriter when close of previous writer fails.
- Replace closeSent field with mutex protected writeErr. Set writeErr on
  any error writing to underlying network connection. Check and return
  writeErr before attempting to write to network connection. Check
  writeErr in NextWriter so application can detect failed connection
  before attempting to write.
- Do not close underlying network connection on error.
- Move message writing state and method flushFrame from Conn to
  messageWriter. This makes error code paths (and the code in general)
  easier to understand.
- Add messageWriter field err to latch errors in messageWriter.

Bonus: Improve test coverage.
2016-11-02 09:59:14 -07:00
Gary Burd 343fff4c5c Fix mask alignment
Fix incorrect computation of buffer alignment in maskBytes. With this
change, all word operations on the buffer are aligned on word
boundaries.
2016-11-02 09:16:35 -07:00
Gary Burd 2aff870ef8 Improve command example
- Close connection cleanly on EOF from command.
2016-10-27 21:05:23 -07:00
Gary Burd 6257d10a8b Improve chat example
- Discuss concurrency and message coalescing in the README.
- Add comments to client.go explaining how concurrency requirements are
  met.
- Prevent developers from calling the Client.write method from outside
  of the writePump goroutine by removing the method. The code is now
  inlined in Client.writPump.
2016-10-25 16:48:54 -07:00
Gary Burd 0b847f2fac Update README.md 2016-10-21 12:35:05 -07:00
Gary Burd 2b825c3f82 Merge pull request #169 from garyburd/master
Improve mask performance
2016-10-21 12:12:30 -07:00
Gary Burd 77f110791c Improve mask performance 2016-10-21 11:11:39 -07:00
Gary Burd 460e0a996e Test w/ Go 1.7 on Travis 2016-10-20 16:33:47 -07:00
Gary Burd 5df680c89f Merge pull request #166 from MaximeHeckel/add-cookiejar
add cookie jar to dialer
2016-10-18 19:33:40 -07:00
Maxime Heckel 56d95f2940 add cookie jar to dialer 2016-10-18 09:56:48 -07:00
Gary Burd 8003df83ee Merge pull request #167 from garyburd/master
enable compression
2016-10-17 17:39:55 -07:00
Gary Burd a0ef436d00 compression: add tests, rename option 2016-10-17 17:30:22 -07:00
Gary Burd 17c3c6b6b9 Merge pull request #164 from artyom/master
Update README to reflect change of Go sub-repo websocket feature
2016-10-17 08:03:37 -07:00
Artyom Pervukhin 99ffb988ce Update README to reflect change of Go sub-repo websocket feature
Closes #164
2016-10-17 11:17:13 +03:00
Cyrus Katrak c09b72d2ee per message compression; only no context modes 2016-10-14 12:08:39 -07:00
Gary Burd 2d1e4548da Simplify dial TLS test
There's no need to fake the connection to example.com because 127.0.0.1
is a host in the net/http/httptest certificate.
2016-09-12 08:30:41 -07:00
Gary Burd a69d25be2f Merge pull request #152 from sambooo/patch-1
Fix typos in chat example
2016-08-02 06:32:03 -07:00
Sam Broughton 295028b997 Fix typos in chat example 2016-08-02 07:24:52 +01:00
Gary Burd 5e2e56d5df Improve chat example
- Remove jQuery.
- Rename Conn to Client to avoid confusion with underlying ws
  connection.
- Remove global variables.
2016-07-18 16:08:34 -07:00
Gary Burd a836c37014 Merge pull request #150 from RHavar/patch-1
Update hub.go
2016-07-10 21:44:50 -07:00
Ryan Havar b5afd49817 Update hub.go 2016-07-10 23:15:05 -05:00
Gary Burd 54f9decdbf Add description to the chat example readme 2016-07-01 11:57:38 -07:00
Gary Burd a87eae1d6f Add hooks to support RFC 7692 (per-message compression extension)
Add newCompressionWriter and newDecompressionReader fields to Conn. When
not nil, these functions are used to create a compression/decompression
wrapper around an underlying message writer/reader.

Add code to set and check for RSV1 frame header bit.

Add functions compressNoContextTakeover and decompressNoContextTakeover
for creating no context takeover wrappers around an underlying message
writer/reader.

Work remaining:

- Add fields to Dialer and Upgrader for specifying compression options.
- Add compression negotiation to Dialer and Upgrader.
- Add function to enable/disable write compression:

    // EnableWriteCompression enables and disables write compression of
    // subsequent text and binary messages. This function is a noop if
    // compression was not negotiated with the peer.
    func (c *Conn) EnableWriteCompression(enable bool) {
            c.enableWriteCompression = enable
    }
2016-06-29 17:03:55 -07:00
Gary Burd b5389d0dc2 Implement RFC 6455, section 4.4 2016-06-29 13:56:55 -07:00
Gary Burd a68708917c Coalesce outbound messages in chat example 2016-06-06 16:20:22 -07:00
Gary Burd 3ddc984058 Merge pull request #136 from reeze/add-handler-getter
Add Ping/Pong handler Getter functions
2016-05-31 22:17:19 -07:00
Reeze Xia c9ce64ea05 Add Ping/Pong handler getter methods 2016-06-01 11:26:10 +08:00
Gary Burd 8b29b78138 Add Sec-WebSocket-Extensions header parser
Also, improve token list header parser.
2016-05-31 09:32:45 -07:00
Gary Burd be01041b66 Reduce memory allocations in NextReader, NextWriter
Redo 8b209f6317 with support for old
versions of Go.
2016-05-31 05:44:45 -07:00
Gary Burd 50d660d6ac Revert "Reduce memory allocations in NextReader, NextWriter"
This reverts commit 8b209f6317.
2016-05-30 01:53:33 -07:00
Gary Burd afffb15196 Merge branch 'varnames' 2016-05-26 21:01:19 -07:00