Commit Graph

259 Commits

Author SHA1 Message Date
Antoine Catton 208061ba28
Docfix: mio::tcp has been renamed to mio::net in its latest version (#164)
This a relic of the old name in the function documentation.
2020-12-30 17:35:40 +01:00
Austaras 4d70f63cbf
Add a custom response builder (#158)
* add custom reponse builder

* change names and shorten implemtation

* Re-format the code

Co-authored-by: Daniel Abramov <dabramov@snapview.de>
2020-12-30 17:35:10 +01:00
Constantin Nickel 8417078ef3 Update to bytes 1.0 2020-12-23 09:37:43 +01:00
Adam Bezecny (DHL IT Services) c8c236056b if streamlined 2020-12-02 22:43:47 +01:00
Adam Bezecny (DHL IT Services) 2e55ed0fcc comment streamlined 2020-12-01 19:21:45 +01:00
Adam Bezecny (DHL IT Services) 9f292d21fc minor fixes 2020-12-01 19:19:45 +01:00
Adam Bezecny (DHL IT Services) 4f7dab5d7b documentation for server_allow_unmasked improved 2020-11-30 19:25:55 +01:00
Adam Bezecny (DHL IT Services) a9adb42343 server_allow_unmasked changed from Option<bool> to bool 2020-11-27 21:38:33 +01:00
Adam Bezecny (DHL IT Services) 0121bf9682 WebSocketConfig extended to allow accepting unmasked client frames 2020-11-26 20:51:50 +01:00
Daniel Abramov fcacea7c9f chore: apply `clippy` 2020-11-17 12:40:52 +01:00
Daniel Abramov 96d9eb75e5 chore: apply `fmt` to the whole project 2020-11-17 12:40:52 +01:00
Daniel Abramov 09f5d34899
use 3 redirects as default for `connect` 2020-11-17 11:17:56 +01:00
Daniel Abramov a8e06d2b39 clean up http error handling 2020-11-16 19:49:17 +01:00
Daniel Abramov 521f1a0767 clean up the redirect logic a bit 2020-11-16 19:25:08 +01:00
Redrield 60f7b0f024 Fix some code-review issues
* Replace Redirection error with a general Http error that owns the
response
* Make the default client connect function iterative instead of
recursive
* Add a limit to the amount of redirects a client will attempt to
perform
2020-11-16 18:13:39 +01:00
Redrield 6bce14fa26 Add facilities to allow clients to follow HTTP 3xx redirects
* The connect() function defined in this crate will automatically follow
redirecting responses.
* Adds Error::Redirection, which is a special case of Error::Http that
extracts the redirection target from the response headers, and stores it
in the error object. Client implementations that build upon tungstenite
can use this to implement redirecting.
* A catch-all solution for redirects is not possible due to the
abstraction transforming socket types to Read + Write, implementations
that use the client_* methods need to handle redirections themselves.
2020-11-16 18:13:39 +01:00
Horki 88ff5f371f matches!: use macros; remove unused imports 2020-10-23 00:51:48 +02:00
philipp 50bc1b5e90 Delegate into_client_request (4) 2020-09-21 18:57:43 +02:00
philipp 064fd9313f Delegate into_client_request (3) 2020-09-21 18:57:43 +02:00
philipp 90345c994a Delegate into_client_request (2) 2020-09-21 18:57:43 +02:00
philipp 4cdc2edab1 Delegate into_client_request 2020-09-21 18:57:43 +02:00
philipp 599b677f5a Avoid temporary variable `fin` 2020-09-21 18:57:39 +02:00
Redrield bcf2b22d9e
Deduplicate the reason line in HTTP responses
The impl of Display for StatusCode already includes the canonical reason
if it exists. The current implementation duplicates this (e.g. the
status line will read "101 Switching Protocols Switching Protocols", or
"400 Bad Request Bad Request".
2020-09-12 22:41:39 -04:00
Sebastian Dröge 849f248a94 Update to sha-1 0.9 2020-07-28 09:34:31 +03:00
Daniel Abramov fd7de42347
Merge pull request #110 from najamelan/doc/mib
doc: be precise about max message sizes.
2020-06-24 17:41:41 +02:00
Daniel Abramov 6791dcc0d6
Merge pull request #119 from kids300/master
Fix ws request subportocol lowercase header
2020-06-24 17:41:22 +02:00
Evgeniy A. Dushistov 5a95f12c6d refactoring/apply_mask: reduce number of usage of unsafe to 1
Plus it should be faster now:

apply_mask/fallback/0   time:   [24.282 ns 24.727 ns 25.255 ns]
apply_mask/fast/0       time:   [11.921 ns 11.963 ns 12.011 ns]
apply_mask/fast_safe/0  time:   [7.9340 ns 7.9807 ns 8.0261 ns]

apply_mask/fallback/1   time:   [25.284 ns 25.710 ns 26.124 ns]
apply_mask/fast/1       time:   [20.433 ns 20.476 ns 20.511 ns]
apply_mask/fast_safe/1  time:   [9.3208 ns 9.3833 ns 9.4470 ns]

apply_mask/fallback/2   time:   [16.051 ns 16.160 ns 16.275 ns]
apply_mask/fast/2       time:   [20.564 ns 20.569 ns 20.574 ns]
apply_mask/fast_safe/2  time:   [9.1449 ns 9.1830 ns 9.2189 ns]

apply_mask/fallback/3   time:   [15.386 ns 15.548 ns 15.715 ns]
apply_mask/fast/3       time:   [18.836 ns 18.867 ns 18.917 ns]
apply_mask/fast_safe/3  time:   [8.3092 ns 8.3566 ns 8.4076 ns]
2020-05-23 18:57:09 +03:00
Evgeniy A. Dushistov 9764ac13a1 infra/apply_mask: test more case for apply_mask
make sure that input with len 0,1,2,3 also tested
2020-05-23 18:53:22 +03:00
Evgeniy A. Dushistov de80b9bced Change Into to From for CloseCode to u16 conversation
As stated in standard library documentation:
> One should always prefer implementing From over Into because implementing From automatically
> provides one with an implementation of Into thanks to the blanket implementation in the standard library.

And this provides the way to use u16::from(close_code)
2020-05-22 01:31:08 +03:00
kids300 fb83e8c791 rm to_string 2020-05-08 16:26:45 +08:00
Yan 16a33df195 fix ws subportocol lowercase header 2020-05-08 15:58:55 +08:00
Mike Pedersen 1f744f1548
Make mask public on FrameHeader
Without the ability to get the mask, having the `FrameHeader` struct as a public type along with functions like `parse` is somewhat useless. I can't see any reason why it shouldn't be public.
2020-04-25 09:58:51 +02:00
Daniel Abramov 0c429cba94 chore: remove deprecated `description()`
Fixes #111
2020-03-28 20:04:08 +01:00
Naja Melan 9c48226c8f chore: Remove needless closing/opening of the impl block on WebSocketContext. 2020-03-21 17:14:45 +01:00
Naja Melan 1f407f1005 feat: Allow reading the configuration.
This allows wrapper types to correctly split data before creating websocket
messages, guaranteeing to respect the max size.

Notably when the WebSocket is provided by user code.
2020-03-21 17:13:57 +01:00
Naja Melan d17f749914 doc: be precise about max message sizes.
If preferred to avoid abbreviations, it could be called mebibytes.
2020-03-21 16:46:51 +01:00
macpp 0bfc217cfc allow firefox to connect 2020-02-01 22:52:41 +01:00
Alexey Galakhov 6b3423292f trivial: fix clippy warning
Signed-off-by: Alexey Galakhov <agalakhov@snapview.de>
2020-01-31 03:13:31 +01:00
Alexey Galakhov 85f211230a websocket: add `can_read()` and `can_write()`
Signed-off-by: Alexey Galakhov <agalakhov@snapview.de>
2020-01-17 21:23:38 +01:00
Alexey Galakhov da3acc107e protocol: handle "Connection reset by peer" in closing state
Signed-off-by: Alexey Galakhov <agalakhov@snapview.de>
2020-01-13 21:50:04 +01:00
Alexey Galakhov c08f2c72ff client: correct port in request
Signed-off-by: Alexey Galakhov <agalakhov@snapview.de>
2020-01-08 13:57:26 +01:00
Alexey Galakhov 9ec11cbc7a client: cover request generation with tests
Signed-off-by: Alexey Galakhov <agalakhov@snapview.de>
2020-01-08 13:26:40 +01:00
Sebastian Dröge c2f713b6bb Update to http 0.2 2019-12-03 09:48:49 +02:00
Alfie John 7ca9bd6f2f Minor grammar fix 2019-12-01 01:13:54 +11:00
Sebastian Dröge 88760b8b59 Fix various clippy warnings 2019-11-24 18:05:40 +01:00
Sebastian Dröge 7a4779b6f6 Run everything through rustfmt 2019-11-24 18:05:40 +01:00
Sebastian Dröge 07d4721ffd Add type aliases for Response/Request with a fixed body type
Simplifies correct usage of the API.
2019-11-24 18:05:40 +01:00
Sebastian Dröge 1ecc4f900d Use Response for the server handshake callback too
And add a public create_response(&Request) function that creates an
initial response. This can be used to simplify integration into existing
HTTP libraries.
2019-11-24 18:05:40 +01:00
Sebastian Dröge 09a9b7ceef Remove custom Request/Response types from server code
Fixes https://github.com/snapview/tungstenite-rs/issues/92
2019-11-24 18:05:37 +01:00
Sebastian Dröge 9020840f84 Remove custom Request/Response types from client code
Fixes https://github.com/snapview/tungstenite-rs/issues/92
2019-11-24 18:05:34 +01:00
Sebastian Dröge 38a7d1a375 Remove custom Headers type and use http::HeaderMap instead
Fixes https://github.com/snapview/tungstenite-rs/issues/92
2019-11-24 18:05:30 +01:00
Danilo Bargen 5f3f4c016e Fix typo in docs 2019-11-06 16:47:31 +01:00
Daniel Abramov c291395d3b Fixes #86 2019-10-24 15:27:44 +02:00
Alexey Galakhov 2903a02ef5 frame: correct possible infinite loop on sending
Closes: #83

Signed-off-by: Alexey Galakhov <agalakhov@snapview.de>
2019-10-08 02:55:53 +02:00
Naja Melan 17fe7987eb Make use of can_read 2019-09-20 21:17:29 +02:00
Daniel Abramov dd602455c4
Merge pull request #79 from najamelan/docs/close
WIP: Add some documentation to WebSocket and Error.
2019-09-20 12:54:26 +02:00
Daniel Abramov b807f76ed1
Update error description
Remove the statement which is not valid anymore.
2019-09-20 12:52:08 +02:00
Naja Melan 1ee3f342aa Consider remote sending a frame after sending a close frame a protocol error.
The websocket RFC explicitly states this is not allowed.
2019-09-19 20:32:04 +02:00
Naja Melan 2918eec1b3 No longer accept to send after close 2019-09-19 20:32:04 +02:00
Daniel Abramov da323e6307
Merge pull request #75 from najamelan/bugfix/return_pong_after_initiate_close
Don't swallow ping/pong while waiting for close acknowledgement
2019-09-19 16:21:23 +02:00
Daniel Abramov 2b2e663264
Merge pull request #73 from dbcfd/expose-machine
Tokio-Tungstenite Async Changes
2019-09-19 16:20:07 +02:00
Danny Browning 6369d48579 Fix compilation error without default features 2019-09-16 06:38:54 -06:00
Naja Melan f818322a25 Add some documentation to WebSocket and Error. 2019-09-14 16:55:47 +02:00
Naja Melan 9379ebe47d Don't swallow ping/pong while waiting for close acknowledgement 2019-09-12 22:16:45 +02:00
Danny Browning 02684b4946 Try removing unpin 2019-09-12 12:58:42 -06:00
Naja Melan bf63a71cd1 cleanup unnecessary dereference 2019-09-12 16:37:23 +02:00
Danny Browning 614a5068fa Tokio-Tungstenite Async Changes
Changes required for tokio-tungstenite async implementation.
2019-09-11 19:06:21 -06:00
Naja Melan 28579b567a Improve WebSocketState interface with Copy, PartialEq, ... 2019-09-12 02:55:07 +02:00
Naja Melan b923ec42c0 Keep processing incoming data even after we have initiated a close handshake. 2019-09-12 01:13:38 +02:00
Artem Vorotnikov cbf80ecc76
Edition 2018, formatting, clippy fixes 2019-08-26 21:05:24 +03:00
Daniel Abramov e2bec4b81f Change the way we return `Err::ConnectionClosed`
This way will ensure that we only return this error once. The previous
solution fixed the problem, but it did not guarantee that ""connection
closed" is returned only once.
2019-08-07 20:03:52 +02:00
Daniel Abramov dbc8bd7b71 Fix issue with hanging server connection 2019-08-07 18:56:40 +02:00
Simon Sapin 4b1d89daf1 Update the url crate to 2.0 2019-07-24 16:48:13 +02:00
Alexey Galakhov 06308b1b3f close: fix autobahn regression
Signed-off-by: Alexey Galakhov <agalakhov@snapview.de>
2019-05-17 00:36:45 +02:00
Alexey Galakhov b8f7d3668e close: refine close semantics
Signed-off-by: Alexey Galakhov <agalakhov@snapview.de>
2019-05-14 02:13:35 +02:00
Alexey Galakhov 6f132208ee server: let callback return HTTP error messages
Signed-off-by: Alexey Galakhov <agalakhov@snapview.de>
2019-05-04 02:15:43 +02:00
Yusuke Sasaki 828eafd400 extract the context values from `WebSocket` 2019-03-26 21:25:52 +09:00
Daniel Abramov c8c3d6290d Make `Close` part of the `Message` enum 2019-02-07 14:26:16 +01:00
Evan Schwartz da85989934 feat: impl Into<Vec<u8>> for Message 2018-09-05 16:49:02 -04:00
Alexey Galakhov a7e87488c4 config: make config settable at runtime
Signed-off-by: Alexey Galakhov <agalakhov@snapview.de>
2018-07-16 15:57:22 +02:00
Alexey Galakhov 9b0a2e0f11 trivial: split public and private impl
Signed-off-by: Alexey Galakhov <agalakhov@snapview.de>
2018-07-16 14:57:14 +02:00
Alexey Galakhov a2e122ab9e refactor: mask: pass mask by value
Signed-off-by: Alexey Galakhov <agalakhov@snapview.de>
2018-07-11 19:04:02 +02:00
Alexey Galakhov e6ebf5ac76 trivial: style fixes
Signed-off-by: Alexey Galakhov <agalakhov@snapview.de>
2018-07-11 18:36:31 +02:00
Alexey Galakhov d2e3602170 frame: fix partial write
Signed-off-by: Alexey Galakhov <agalakhov@snapview.de>
2018-07-11 18:29:20 +02:00
Alexey Galakhov 3772aaf163 chore: introduce frame size limit
Signed-off-by: Alexey Galakhov <agalakhov@snapview.de>
2018-07-11 02:09:16 +02:00
Alexey Galakhov 50d1371e52 frame: cleanup frame API
Signed-off-by: Alexey Galakhov <agalakhov@snapview.de>
2018-07-11 00:44:44 +02:00
Alexey Galakhov 75aa0d54f3 refactor: parse header separately from payload
Signed-off-by: Alexey Galakhov <agalakhov@snapview.de>
2018-07-11 00:37:06 +02:00
Alexey Galakhov 20242d19f7 config: protocol: add message size limiting
Signed-off-by: Alexey Galakhov <agalakhov@snapview.de>
2018-07-10 18:32:50 +02:00
Alexey Galakhov a4f885f69f protocol: improve write responsibility
Signed-off-by: Alexey Galakhov <agalakhov@snapview.de>
2018-07-10 18:32:50 +02:00
Alexey Galakhov e4a52cde05 mask: update for actual Rust version
Closes #35

Signed-off-by: Alexey Galakhov <agalakhov@snapview.de>
2018-07-10 18:28:03 +02:00
Alexey Galakhov cb671e1abc trivial: improve documentation
Signed-off-by: Alexey Galakhov <agalakhov@snapview.de>
2018-07-10 18:10:02 +02:00
Ran Benita 4cfe9a2be1 frame: eliminate an unsafe when reading message data into the buffer
The reason for the unsafe was presumably to avoid copying or
zero-initializing. This achieves the same but using only safe functions.

Note: there is no zero-initializing here because Cursor is "trusted" to
not read from the buffer and so skips the initialization:
https://github.com/rust-lang/rust/blob/master/src/libstd/io/cursor.rs#L241
(the Take wrapper delegates to its inner).
2018-07-10 17:51:31 +03:00
Alexey Galakhov fdb1a0ed50 frame: reject bad opcodes early
Signed-off-by: Alexey Galakhov <agalakhov@snapview.de>
2018-07-02 19:05:54 +02:00
Alexey Galakhov 9bd65feaeb frame: reject frames that are too big for the RAM
Fixes #34.

Signed-off-by: Alexey Galakhov <agalakhov@snapview.de>
2018-07-02 18:14:37 +02:00
Alexey Galakhov 977c6e7c7a refactor: remove transmute in favor of safe code
Signed-off-by: Alexey Galakhov <agalakhov@snapview.de>
2018-07-02 18:14:37 +02:00
Alexey Galakhov c0cde68999 frame: fix integer overflow
This is a security fix.
Fixes #33.

Signed-off-by: Alexey Galakhov <agalakhov@snapview.de>
2018-07-02 18:14:10 +02:00
Alexey Galakhov b93abcf900
Merge pull request #27 from snapview/websocket-config
Allow the configuration of `WebSocket`
2018-06-26 11:35:34 +02:00
Daniel Abramov 3a58069db2 Create helpers for config-like functions
As suggested by @agalakhov
2018-06-26 11:12:57 +02:00
Ryan Leckey 51e7ba3f39 Switch from sha1 to sha-1 2018-06-25 22:13:45 -07:00
Ryan Leckey ef8e41f63f prepare for native-tls 0.2 2018-06-19 11:10:08 -07:00
Daniel Abramov 00303fa60c Make the websocket configurable 2018-05-25 10:41:16 +02:00
Teddy DeRego 5742c822ee WebSocket::write_message will no longer buffer unlimited messages - it will only buffer a configurable number of outbound messages. Needed for snapview/tokio-tungstenite#35. 2018-04-14 17:36:59 -07:00
Sean Schwartz 66d2c15f2d Derive Debugs
Deny missing debug and resolve resulting errors to satisfy:
https://rust-lang-nursery.github.io/api-guidelines/debuggability.html#all-public-types-implement-debug-c-debug

Requires updated input_buffer pushed to crates.io:
 - Resolved build errors by using github version of code until new version available on crates.io

Upgrade env_logger dev-dependency to v0.5.3
 - Removed unwrap call from env_logger::init()  as it is no longer needed.
2018-01-21 10:36:48 -06:00
Alexey Galakhov 7dc2be7eab Update for Rust 1.23
Signed-off-by: Alexey Galakhov <agalakhov@snapview.de>
2018-01-15 11:01:02 +01:00
Alexey Galakhov 6f8c4e7034 Use input_buffer as separate crate.
Signed-off-by: Alexey Galakhov <agalakhov@snapview.de>
2017-12-12 01:19:05 +01:00
Alexey Galakhov 3091d11566 callback static dispatch
Signed-off-by: Alexey Galakhov <agalakhov@snapview.de>
2017-10-09 10:36:12 +02:00
Daniel Abramov c4013ccad3 Improve the `handshake::client::Request` structure 2017-09-01 17:04:56 +02:00
Daniel Abramov 5982d4094d Update README and examples 2017-07-28 14:37:21 +02:00
Daniel Abramov 44a15c9eab Implements #6 (client/server headers access) 2017-07-28 14:36:24 +02:00
Daniel Abramov f34c488217 Add basic support for examining headers (#6) 2017-07-28 14:35:42 +02:00
Alex Crichton 9f6f42766e Add `Ping` and `Pong` variants to `Message`
This'll allow removal/deprecation of the `send_ping` custom method but also
allow applications to react to `Pong` messages as appropriate.

Closes #16
2017-07-25 14:36:42 -07:00
Alexey Galakhov 6faf90cd7b trivial: remove commented-out code
Signed-off-by: Alexey Galakhov <agalakhov@snapview.de>
2017-05-23 03:21:39 +02:00
Alexey Galakhov bd9ac9673e chore: cleanup docs and warnings, strict docs
Signed-off-by: Alexey Galakhov <agalakhov@snapview.de>
2017-05-23 02:50:29 +02:00
Alexey Galakhov 686bc51b84 stream: set TCP_NODELAY on connect
Signed-off-by: Alexey Galakhov <agalakhov@snapview.de>
2017-05-23 02:14:34 +02:00
Alexey Galakhov f696771069 Generalize connect() interface.
Signed-off-by: Alexey Galakhov <agalakhov@snapview.de>
2017-05-22 23:45:50 +02:00
Alexey Galakhov e3c0ec30c8 Fix close handling while read.
Signed-off-by: Alexey Galakhov <agalakhov@snapview.de>
2017-05-19 17:54:02 +02:00
Alexey Galakhov 22f7df0b46 Fix possible deadlock in handshake.
Signed-off-by: Alexey Galakhov <agalakhov@snapview.de>
2017-05-18 10:18:16 +02:00
Denis Andrejew 624f1dec1a improve doc in protocol/mod.rs 2017-05-05 15:04:53 +02:00
Alexey Galakhov 6d10b40215 Flush stream after sending message
Signed-off-by: Alexey Galakhov <agalakhov@snapview.de>
2017-04-11 16:15:00 +02:00
Alexey Galakhov 3abe419e98 Fix fast masking of unaligned data
Signed-off-by: Alexey Galakhov <agalakhov@snapview.de>
2017-04-05 15:47:37 +02:00
Alexey Galakhov 01a9211a84 Move mask functions into a separate file
Signed-off-by: Alexey Galakhov <agalakhov@snapview.de>
2017-04-05 11:41:03 +02:00
Alexey Galakhov 9a3b29b05e Merge branch 'devel' 2017-04-04 13:25:14 +02:00
Alexey Galakhov d29e3948d2 Add Debug, Display and Error to HandshakeError
Signed-off-by: Alexey Galakhov <agalakhov@snapview.de>
2017-04-04 13:18:57 +02:00
Alexey Galakhov 24f3bb7807 Add the possibility to pass extra request headers.
Closes: #5

Suggestions for a more convenient API are welcome.

Signed-off-by: Alexey Galakhov <agalakhov@snapview.de>
2017-04-03 21:34:14 +02:00
Alexey Galakhov 66e30b2767 Return close frame with ConnectionClosed
This is a breaking change, thus bump the API version.

Closes: #10

Signed-off-by: Alexey Galakhov <agalakhov@snapview.de>
2017-04-03 21:21:28 +02:00
Alexey Galakhov 8df6bdbeb0 Add Display to CloseFrame and CloseCode
Signed-off-by: Alexey Galakhov <agalakhov@snapview.de>
2017-04-03 16:43:17 +02:00
Alexey Galakhov bd37c71609 Replace tuple with CloseFrame struct
Signed-off-by: Alexey Galakhov <agalakhov@snapview.de>
2017-04-03 15:52:33 +02:00
Alexey Galakhov 0e8113e6e0 Merge branch 'devel' 2017-04-03 13:39:54 +02:00
Ran Benita 8e49bea00f Fix InputBuffer::reserve() to not be a no-op
The current implementation uses the `remaining_mut()` function from the
bytes::BufMut implementation for Vec<u8>.

In terms of the BufMut trait, a Vec buffer has infinite capacity - you
can always write more to the buffer, since the Vec grows as needed.
Hence, the `remaining_mut` here actually returns +∞ (actually,
`usize::MAX - len`).

So the first `if` is always true, and the calls to `reserve` never
actually allocate the appropriate space. What happens instead is that
the `bytes_mut()` call in `read_from` picks up the slack, but it merely
grows the buffer a 64 bytes at a time, which slows things down.

This changes the check to use the Vec capacity instead of
`remaining_mut`. In my profile (sending 100,000 10KiB messages back and
forth), this reduces `__memmove_avx_unaligned_erms`'s share of the
total runtime from ~77% to ~53%.
2017-03-27 21:15:15 +03:00
Ran Benita be834ac261 Replace unsafe endianness code with byteorder functions 2017-03-26 00:29:24 +03:00
Ran Benita ae30b8cd76 Apply a couple trivial clippy suggestions 2017-03-26 00:03:04 +03:00
Ran Benita 8955b55e62 Simplify concatenation code using slice::concat 2017-03-26 00:03:03 +03:00
Ran Benita 76e80ca9a3 Only allocate error message if the error occurred
Suggested by clippy:

warning: use of `ok_or` followed by a function call
  --> src/handshake/server.rs:20:19
   |
20 |           let key = self.headers.find_first("Sec-WebSocket-Key")
   |  ___________________^ starting here...
21 | |             .ok_or(Error::Protocol("Missing Sec-WebSocket-Key".into()))?;
   | |_______________________________________________________________________^ ...ending here
   |
   = note: #[warn(or_fun_call)] on by default
help: try this
   |         let key = self.headers.find_first("Sec-WebSocket-Key").ok_or_else(|| Error::Protocol("Missing Sec-WebSocket-Key".into()))?;
   = help: for further information visit https://github.com/Manishearth/rust-clippy/wiki#or_fun_call
2017-03-26 00:02:34 +03:00
Ran Benita 3c600aa138 Speed up apply_mask() - part 2
This is using some unsafe code and assumptions about alignment to speed
up apply_mask() more.

In profiles, this optimization reduces it from ~55% of the total runtime
to ~7%.
2017-03-26 00:02:32 +03:00
Ran Benita dd96d3b9d4 Speed up apply_mask()
This function is the most speed-critical in the library. In profiles,
this optimization reduces it from ~75% of the profile to ~55%.

I have tried several approaches, but didn't manage to improve on this
one (LLVM already unrolls the loop here). Though I'm sure it is possible.
2017-03-26 00:01:45 +03:00
Ran Benita ea4b5e4df0 Remove unnecessary transmute in generate_mask()
rand::Rand has
    impl<T> Rand for [T; 16] where T: Rand
so we don't need to simulate it ourselves.
2017-03-25 23:59:03 +03:00
Alexey Galakhov e0eecd28b1 Refactor TLS handling
Signed-off-by: Alexey Galakhov <agalakhov@snapview.de>
2017-03-22 19:43:33 +01:00
Alexey Galakhov e2b7b73e72 Improve documentation.
Signed-off-by: Alexey Galakhov <agalakhov@snapview.de>
2017-03-22 17:09:39 +01:00
Alexey Galakhov b057cf0096 Update for the version 0.7 of the utf8 crate.
Signed-off-by: Alexey Galakhov <agalakhov@snapview.de>
2017-03-21 22:22:24 +01:00
Alexey Galakhov 53aa24b06b Fix warnings
Signed-off-by: Alexey Galakhov <agalakhov@snapview.de>
2017-03-17 16:05:16 +01:00
Alexey Galakhov 037dea1f8e Add possibility to send pings
Signed-off-by: Alexey Galakhov <agalakhov@snapview.de>
2017-03-17 16:01:28 +01:00
Alexey Galakhov ac580a666b Reexport useful components
Signed-off-by: Alexey Galakhov <agalakhov@snapview.de>
2017-03-17 15:57:12 +01:00
Alexey Galakhov 06a39b4962 protocol: add get_ref() and get_mut()
Signed-off-by: Alexey Galakhov <agalakhov@snapview.de>
2017-03-15 02:21:47 +01:00
Alexey Galakhov 9e00140e19 trivial: debug logging cleanup 2017-03-14 23:26:23 +01:00
Alexey Galakhov c6d3dd6404 refactor: fix unit tests for new API 2017-03-13 19:17:31 +01:00
Alexey Galakhov b7557f1baa refactor: make handshake completely async 2017-03-13 19:17:05 +01:00
Alexey Galakhov 334ceab2b0 protocol: less strict trait requirements 2017-03-10 03:54:56 +01:00
Alexey Galakhov 604e2021ce protocol: add write_pending() functions
The semantics of write_message() and write_frame()
is changed accordingly.
2017-02-17 18:13:30 +01:00
Alexey Galakhov e6b658d94f handshake: add the ability to iterate over headers. 2017-02-09 18:04:38 +01:00
Alexey Galakhov d27f768599 protocol: fix infinite loop in non-blocking mode 2017-02-07 10:32:59 +01:00