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 .
7 years ago
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.
7 years ago
Alexey Galakhov
7dc2be7eab
Update for Rust 1.23
...
Signed-off-by: Alexey Galakhov <agalakhov@snapview.de>
7 years ago
Alexey Galakhov
6f8c4e7034
Use input_buffer as separate crate.
...
Signed-off-by: Alexey Galakhov <agalakhov@snapview.de>
7 years ago
Alexey Galakhov
3091d11566
callback static dispatch
...
Signed-off-by: Alexey Galakhov <agalakhov@snapview.de>
7 years ago
Daniel Abramov
c4013ccad3
Improve the `handshake::client::Request` structure
7 years ago
Daniel Abramov
5982d4094d
Update README and examples
7 years ago
Daniel Abramov
44a15c9eab
Implements #6 (client/server headers access)
7 years ago
Daniel Abramov
f34c488217
Add basic support for examining headers ( #6 )
7 years ago
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
7 years ago
Alexey Galakhov
6faf90cd7b
trivial: remove commented-out code
...
Signed-off-by: Alexey Galakhov <agalakhov@snapview.de>
8 years ago
Alexey Galakhov
bd9ac9673e
chore: cleanup docs and warnings, strict docs
...
Signed-off-by: Alexey Galakhov <agalakhov@snapview.de>
8 years ago
Alexey Galakhov
686bc51b84
stream: set TCP_NODELAY on connect
...
Signed-off-by: Alexey Galakhov <agalakhov@snapview.de>
8 years ago
Alexey Galakhov
f696771069
Generalize connect() interface.
...
Signed-off-by: Alexey Galakhov <agalakhov@snapview.de>
8 years ago
Alexey Galakhov
e3c0ec30c8
Fix close handling while read.
...
Signed-off-by: Alexey Galakhov <agalakhov@snapview.de>
8 years ago
Alexey Galakhov
22f7df0b46
Fix possible deadlock in handshake.
...
Signed-off-by: Alexey Galakhov <agalakhov@snapview.de>
8 years ago
Denis Andrejew
624f1dec1a
improve doc in protocol/mod.rs
8 years ago
Alexey Galakhov
6d10b40215
Flush stream after sending message
...
Signed-off-by: Alexey Galakhov <agalakhov@snapview.de>
8 years ago
Alexey Galakhov
3abe419e98
Fix fast masking of unaligned data
...
Signed-off-by: Alexey Galakhov <agalakhov@snapview.de>
8 years ago
Alexey Galakhov
01a9211a84
Move mask functions into a separate file
...
Signed-off-by: Alexey Galakhov <agalakhov@snapview.de>
8 years ago
Alexey Galakhov
d29e3948d2
Add Debug, Display and Error to HandshakeError
...
Signed-off-by: Alexey Galakhov <agalakhov@snapview.de>
8 years ago
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>
8 years ago
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>
8 years ago
Alexey Galakhov
8df6bdbeb0
Add Display to CloseFrame and CloseCode
...
Signed-off-by: Alexey Galakhov <agalakhov@snapview.de>
8 years ago
Alexey Galakhov
bd37c71609
Replace tuple with CloseFrame struct
...
Signed-off-by: Alexey Galakhov <agalakhov@snapview.de>
8 years ago
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%.
8 years ago
Ran Benita
be834ac261
Replace unsafe endianness code with byteorder functions
8 years ago
Ran Benita
ae30b8cd76
Apply a couple trivial clippy suggestions
8 years ago
Ran Benita
8955b55e62
Simplify concatenation code using slice::concat
8 years ago
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
8 years ago
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%.
8 years ago
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.
8 years ago
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.
8 years ago
Alexey Galakhov
e0eecd28b1
Refactor TLS handling
...
Signed-off-by: Alexey Galakhov <agalakhov@snapview.de>
8 years ago
Alexey Galakhov
e2b7b73e72
Improve documentation.
...
Signed-off-by: Alexey Galakhov <agalakhov@snapview.de>
8 years ago
Alexey Galakhov
b057cf0096
Update for the version 0.7 of the utf8 crate.
...
Signed-off-by: Alexey Galakhov <agalakhov@snapview.de>
8 years ago
Alexey Galakhov
53aa24b06b
Fix warnings
...
Signed-off-by: Alexey Galakhov <agalakhov@snapview.de>
8 years ago
Alexey Galakhov
037dea1f8e
Add possibility to send pings
...
Signed-off-by: Alexey Galakhov <agalakhov@snapview.de>
8 years ago
Alexey Galakhov
ac580a666b
Reexport useful components
...
Signed-off-by: Alexey Galakhov <agalakhov@snapview.de>
8 years ago
Alexey Galakhov
06a39b4962
protocol: add get_ref() and get_mut()
...
Signed-off-by: Alexey Galakhov <agalakhov@snapview.de>
8 years ago
Alexey Galakhov
9e00140e19
trivial: debug logging cleanup
8 years ago
Alexey Galakhov
c6d3dd6404
refactor: fix unit tests for new API
8 years ago
Alexey Galakhov
b7557f1baa
refactor: make handshake completely async
8 years ago
Alexey Galakhov
334ceab2b0
protocol: less strict trait requirements
8 years ago
Alexey Galakhov
604e2021ce
protocol: add write_pending() functions
...
The semantics of write_message() and write_frame()
is changed accordingly.
8 years ago
Alexey Galakhov
e6b658d94f
handshake: add the ability to iterate over headers.
8 years ago
Alexey Galakhov
d27f768599
protocol: fix infinite loop in non-blocking mode
8 years ago
Daniel Abramov
93843a1290
Fix `WouldBlock` error handling for the handshakes
8 years ago
Daniel Abramov
0938a17552
Move `no_block()` related stuff into seperate mod
8 years ago
Alexey Galakhov
3bb4331f4f
protocol: fix bug with async handling
8 years ago