Commit Graph

259 Commits

Author SHA1 Message Date
RustUser246 68daa29b19 add support for batching websocket messages 2022-07-27 21:13:54 +01:00
n3oney 80d0547fab
fix: uppercase origin header 2022-06-18 23:31:42 +02:00
Daniel Abramov b8ccbcf2a1 chore: update the documentation
Fixes #280.
2022-04-19 19:39:19 +02:00
kangalioo fa70a370c8 Downgrade MSRV to 1.51 2022-03-19 23:46:51 +01:00
Daniel Abramov d9a1ab2cb2
Merge pull request #266 from teozkr/chore/rust-1.56
Downgrade MSRV to 1.56
2022-02-21 15:38:44 +01:00
Daniel Abramov 2171c997f5 test: add a unit test for invalid `http::Request`
This is to make sure that we don't panic anymore in such cases:
https://github.com/snapview/tungstenite-rs/pull/267
2022-02-21 15:37:13 +01:00
Sebastian Dröge 1a48959adc `HeaderName::from_static` requires all-lowercase HTTP2 compatible header names
and was passed header names with uppercase characters instead, which
made it panic.
2022-02-21 16:21:52 +02:00
Teo Klestrup Röijezon d21c7b53ca Downgrade MSRV to 1.56 2022-02-21 13:04:36 +01:00
Daniel Abramov d661f57224 client: overhaul of the request generation 2022-02-04 13:42:55 +01:00
Daniel Abramov 1b999136ef clippy: fix warnings 2022-02-03 19:38:11 +01:00
Daniel Abramov cd79500d25
Merge pull request #250 from Voronar/message_raw_frame
feature: Raw frame message
2021-12-08 18:29:11 +01:00
Kirill A. Khalitov 469aaf37be feature: Raw fragment message 2021-11-22 20:33:42 +03:00
Daniel Abramov 68541e4095
Merge pull request #227 from LYF1999/master
fix: write some header twice
2021-11-03 19:00:29 +01:00
Daniel Abramov 4729b0f000
Merge pull request #244 from dnaka91/rustls-0.20
Upgrade to rustls 0.20
2021-10-27 15:11:53 +02:00
Daniel Abramov 54cca09538
Merge pull request #241 from PhotonQuantum/master
Move ReadBuffer chunk to heap
2021-10-27 10:47:51 +02:00
Florian Uekermann 3e45100f5d
replace unwrap with ? 2021-10-23 00:03:09 +02:00
Daniel Abramov 951411096d
Merge pull request #246 from snapview/echo-close-code
Echo the `CloseFrame` when close is initiated
2021-10-20 17:44:54 +02:00
Daniel Abramov 6c4d2bab04 Fix newly introduced clippy warnings 2021-10-19 22:43:30 +02:00
Daniel Abramov 5ad8cef6ff Echo the `CloseFrame` when close is initiated 2021-10-19 22:40:21 +02:00
Dominik Nakamura f4bb653aa0
Upgrade to rustls 0.20 2021-10-18 11:27:03 +09:00
PhotonQuantum 3f5d0985f0
Move ReadBuffer chunk to heap 2021-10-15 07:15:25 +08:00
yifei 9f563561a4 fix: return err if try to overwrite standard hedaer 2021-08-20 00:35:42 +08:00
Dominik Nakamura 32450ae5af
Add a connector to configure TLS config 2021-07-23 21:26:44 +09:00
Dominik Nakamura 5e0fde5dc6
Fix clippy warnings and deprecated settings 2021-07-21 10:43:44 +09:00
Dominik Nakamura 8b029baa8d
Fix wrong feature name when setting certs 2021-07-14 00:21:37 +09:00
Dominik Nakamura 3efb0544c6
Remove the rustls-tls feature flag 2021-07-13 17:46:48 +09:00
Dominik Nakamura 3fbd583f29
Enable root cert providers through feature flags 2021-07-12 22:37:52 +09:00
Daniel Abramov 83722c24aa Clean up the read portion of the buffer 2021-07-06 16:33:44 +02:00
Daniel Abramov ddddd791ef Implement benchmarks for buffers 2021-07-05 18:38:10 +02:00
Daniel Abramov 2787031c2f Replace `InputBuffer` with a faster alternative
We're also deprecating the usage of `input_buffer` crate, see:
https://github.com/snapview/input_buffer/issues/6#issuecomment-870548303
2021-07-05 18:38:06 +02:00
Daniel Abramov 8c3172c014
Merge pull request #205 from yusdacra/master
downgrade webpki, use rustls-native-certs instead of webpki-roots
2021-05-27 13:09:30 +02:00
Yusuf Bera Ertan a729b37b22
Update src/client.rs
Co-authored-by: Daniel Abramov <inetcrack2@gmail.com>
2021-05-26 16:07:54 +03:00
Teymour Aldridge 94aef58646
Fix a typo in a docstring 2021-05-24 16:09:33 +01:00
Yusuf Bera Ertan d7e2f0a72a
downgrade webpki, use rusttls-native-certs instead of webpki-roots 2021-05-19 01:54:50 +03:00
Maarten de Vries abebb330af Implement From<CapacityError> and From<UrlError> for Error. 2021-03-03 21:04:42 +01:00
Lukas Kalbertodt 5ce9e7ca39
Add `From<ProtocolError>` impl for `Error` 2021-03-02 15:57:44 +01:00
Dominik Nakamura c101024c28
Add support for rustls as TLS backend (#166)
* Add support for rustls as TLS backend

* Use a "use-*" prefix for the TLS features

* Only enable rustls if native-tls is not enabled

* Allows several TLS components to coexist

* Update docs for rustls mentions

* Enable all features on docs.rs

* Rename TLS feature flags from "use-*" to "*-tls"

* Make native-tls the default

* Move TLS related errors to a separate enum

* Add changelog entry about rustls support

* Fix wrong naming in main error enum

* Simplify docs about tls feature flag usage
2021-02-08 13:58:42 +01:00
Maarten de Vries 96612748d1 Expose `handshake::derive_accept_key` as public API. 2021-02-06 18:41:58 +01:00
WiredSound 79dcf9f77c Use matches! macro in tests 2021-01-11 14:14:36 +00:00
WiredSound 3e485ddb96 Rename UrlErrorType to just UrlError, implement using thiserror 2021-01-09 21:31:03 +00:00
WiredSound 98377cf3dd Rename ProtocolErrorType to just ProtocolError, implement using thiserror 2021-01-09 21:23:03 +00:00
WiredSound 652a6b776e Rename CapacityErrorType to just CapacityError, implement using thiserror 2021-01-09 21:12:33 +00:00
WiredSound e6d66698a3 Use thiserror to streamline the implementation of the main Error type 2021-01-09 21:04:41 +00:00
WiredSound 78d59f9266 Escape square brackets in doc comment 2021-01-09 20:38:34 +00:00
WiredSound 0b34bee94f Add capacity error types 2021-01-09 20:38:34 +00:00
WiredSound aaebb432f0 Fix clippy warnings 2021-01-09 20:38:34 +00:00
WiredSound 6f846da0e3 Add protocol error types 2021-01-09 20:38:30 +00:00
WiredSound 34c6e63d87 Add specific URL error types 2021-01-09 20:30:54 +00:00
Daniel Abramov e1ae3872cd
Merge pull request #159 from adambezecny/master
WebSocketConfig extended to allow accepting unmasked client frames
2021-01-08 12:52:57 +01:00
Dominik Nakamura 82e09ea025
Remove remaining dynamic dispatch usage 2021-01-02 16:45:50 +09:00
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