1
0
Fork 0
mirror of https://github.com/actix/actix-web.git synced 2024-07-01 19:47:18 +00:00
Commit graph

320 commits

Author SHA1 Message Date
Yuki Okushi b9b52079e0 Update actix-tls to 2.0.0-alpha.1 2020-03-04 15:10:23 +09:00
Yuki Okushi 117d28f7ba Update actix-connect to 2.0.0-alpha.1 2020-03-04 15:09:31 +09:00
Yuki Okushi b4d63667df Demote lint level to warn 2020-02-27 22:39:11 +09:00
Yuki Okushi 6cc83dbb67 Allow clippy lint for compatibility 2020-02-27 12:45:11 +09:00
Yuki Okushi 15a2587887 Bump up to 2.0.0-alpha.1 2020-02-27 12:39:04 +09:00
Yuki Okushi 0173f99726 Update changelog 2020-02-27 12:39:04 +09:00
Yuki Okushi f27dd19093 Fix Clippy warnings 2020-02-27 12:39:04 +09:00
Yuki Okushi 7ba14fd113 Run rustfmt 2020-02-27 11:10:55 +09:00
Yuki Okushi 903ae47baa dev-deps: Update env_logger to 0.7 2020-02-27 11:08:45 +09:00
Yuki Okushi cd1765035c Avoid re-definition 2020-02-27 09:42:32 +09:00
Maksym Vorobiov ea28219d0f reenable actix-http test-ws 2020-02-27 09:42:32 +09:00
Maksym Vorobiov 0a86907dd2 use mem::replace instead of mem::take rust 1.40+ 2020-02-27 09:37:05 +09:00
Maksym Vorobiov 78749a4b7e rollback actix-http version change 2020-02-27 09:37:05 +09:00
Maksym Vorobiov de815dd99c Fixed condition for finishing transfer of response 2020-02-27 09:37:05 +09:00
Maksym Vorobiov e6078bf792 Fix EncoderBody enum to align with Body::Message 2020-02-27 09:37:05 +09:00
Maksym Vorobiov a84b37199a Add Unpin to Body to get rid of unsafe in MessageBody 2020-02-27 09:37:05 +09:00
Maksym Vorobiov c05f9475c5 refactor dispatcher to avoid possible UB with DispatcherState Pin 2020-02-27 09:37:05 +09:00
Maksym Vorobiov 69dab0063c Get rid of one more unsafe 2020-02-27 09:37:05 +09:00
Maksym Vorobiov ec5c779732 unlink MessageBody from Unpin 2020-02-27 09:37:05 +09:00
Maksym Vorobiov 2e2ea7ab80 remove extra whitespaces and Unpins 2020-02-27 09:37:05 +09:00
Maksym Vorobiov eeebc653fd change actix-http version to alpha 2020-02-27 09:37:05 +09:00
Maksym Vorobiov 09a391a3ca rollback changes to actix-web, awc and test-server for now 2020-02-27 09:37:05 +09:00
Maksym Vorobiov 62aba424e2 Rollback actix-http-test dependency to show the issue 2020-02-27 09:37:05 +09:00
Maksym Vorobiov 9d04b250f9 This is a squashed commit:
- Convert MessageBody to accept Pin in poll_next

- add CHANGES and increase versions aligned to semver

- update crates to accomodate MessageBody Pin change

- fix tests and dependencies
2020-02-27 09:37:05 +09:00
Maksym Vorobiov a4148de226 add test crashing with segfault according to #1321 2020-02-27 09:36:30 +09:00
Maxim Vorobjov 48ef4d7a26
Add actix-http support for actix error messages (#1379)
* Moved actix-http for actix from actix crate

* remove resolver feature

* renamed actix feature to actor

* fixed doc attr for actors, add documentation
2020-02-27 09:34:49 +09:00
Aaron Hill 71c4bd1b30
Remove uses of Pin::new_unchecked in h1 Dispatcher (#1374)
This removes the last uses of unsafe `Pin` functions in actix-web.

This PR adds a `Pin<Box<_>>` wrapper to `DispatcherState::Upgrade`,
`State::ExpectCall`, and `State::ServiceCall`.

The previous uses of the futures `State::ExpectCall` and `State::ServiceCall`
were Undefined Behavior - a future was obtained from `self.expect.call`
or `self.service.call`, pinned on the stack, and then immediately
returned from `handle_request`. The only alternative to using `Box::pin`
would be to refactor `handle_request` to write the futures directly into
their final location, or avoid polling them before they are returned.

The previous use of `DispatcherState::Upgrade` doesn't seem to be
unsound. However, having data pinned inside an enum that we
`std::mem::replace` would require some careful `unsafe` code to ensure
that we never call `std::mem::replace` when the active variant contains
pinned data. By using `Box::pin`, we any possibility of future
refactoring accidentally introducing undefined behavior.

Co-authored-by: Yuki Okushi <huyuumi.dev@gmail.com>
2020-02-26 08:21:05 +09:00
Yuki Okushi 2a72e8d119
Merge branch 'master' into replace-unsafe-content-length-helper 2020-02-25 14:30:04 +09:00
Yuki Okushi 845ce3cf34 Fix doc comment 2020-02-25 07:46:03 +09:00
Rob Ede 94da08f506
increase content-length fast path to responses up to 1MB 2020-02-24 20:58:41 +00:00
Yuki Okushi c8ccc69b93 actix-http: update time to 0.2.7 2020-02-23 07:09:00 +09:00
Daniel YU 245f96868a
impl downcast_ref for MessageBody (#1287)
Co-authored-by: Yuki Okushi <huyuumi.dev@gmail.com>
2020-02-21 13:31:51 +09:00
Aaron Hill e6811e8818
Use #[pin_project] with ConnectorPoolSupport
This removes a use of `Pin::get_unchecked_mut`
2020-02-19 21:42:53 -05:00
Rob Ede f266b44cb0
replace unsafe blocks in write_usize helper 2020-02-16 15:20:25 +00:00
Rob Ede 31a3515e90
add safe vs unsafe benchmarks 2020-02-16 14:31:06 +00:00
Rob Ede 82b2786d6b
replace unsafe content length implementation 2020-02-16 14:31:05 +00:00
zero-systems 728b944360
Extensions module improvement and tests. (#1297)
* replace get.is_some to contains_key

* Add tests

* remove unnecessary box cast

* fix missing uints

* asserts fix

Co-authored-by: Yuki Okushi <huyuumi.dev@gmail.com>
2020-02-07 16:08:25 +09:00
Aaron Hill fe13789345
Use Pin<Box<S>> in BodyStream and SizedStream (#1328)
Fixes #1321

A better fix would be to change `MessageBody` to take a `Pin<&mut
Self>`, rather than a `Pin<&mut Self>`. This will avoid requiring the
use of `Box` for all consumers by allowing the caller to determine how
to pin the `MessageBody` implementation (e.g. via stack pinning).

However, doing so is a breaking change that will affect every user of
`MessageBody`. By pinning the inner stream ourselves, we can fix the
undefined behavior without breaking the API.

I've included @sebzim4500's reproduction case as a new test case.
However, due to the nature of undefined behavior, this could pass (and
not segfault) even if underlying issue were to regress.

Unfortunately, until rust-lang/unsafe-code-guidelines#148 is resolved,
it's not even possible to write a Miri test that will pass when the bug
is fixed.

Co-authored-by: Yuki Okushi <huyuumi.dev@gmail.com>
2020-01-31 09:39:34 +09:00
Aaron Hill 3033f187d2
Enforce safety of downcast_ref at compile time. (#1326)
* Enforce safety of `downcast_ref` at compile time.

The safety of `downcast_ref` requires that `__private_get_type_id__` not
be overriden by callers, since the returned `TypeId` is used to check if
the cast is safe. However, all trait methods in Rust are public, so
users can override `__private_get_type_id__` despite it being
`#[doc(hidden)]`.

This commit makes `__private_get_type_id__` return a type with a private
constructor, ensuring that the only possible implementation is the
default implementation. A more detailed explanation is provided in the
comments added to the file.

Note that the standard library was affected by this type of issue with
the `Error::type_id` function: see https://blog.rust-lang.org/2019/05/14/Rust-1.34.2.html#whats-in-1.34.2-stable

Co-authored-by: Yuki Okushi <huyuumi.dev@gmail.com>
2020-01-30 23:43:35 +09:00
Aaron Hill 276a5a3ee4
Replace UnsafeCell with Cell in DateServiceInner (#1325)
* Replace `UnsafeCell` with `Cell` in `DateServiceInner`

This ensures that it's impossible to cause undefined behavior by
accidentally violating Rust's aliasing rules (e.g. passing a closure to
`set_date` which ends up invoking `reset` or `update` on the inner
`DateServiceInner`).

There might be a tiny amount of overhead from copying the `Option<(Date,
Instant)>` rather than taking a reference, but it shouldn't be
measurable.

Since the wrapped type is `Copy`, a `Cell` can be used, avoiding the
runtime overhead of a `RefCell`.

Co-authored-by: Yuki Okushi <huyuumi.dev@gmail.com>
2020-01-29 21:05:08 +09:00
kevinpoitra e634e64847 Upgrade time to 0.2.5 (#1254)
* Use `OffsetDateTime` instead of `PrimitiveDateTime`

* Parse time strings with `PrimitiveDateTime::parse` instead of `OffsetDateTime::parse`

* Remove unused `time` dependency from actix-multipart

* Fix a few errors with time related tests from the `time` upgrade

* Implement logic to convert a RFC 850 two-digit year into a full length year, and organize time parsing related functions

* Upgrade `time` to 0.2.2

* Correctly parse C's asctime time format using time 0.2's new format patterns

* Update CHANGES.md

* Use `time` without any of its deprecated functions

* Enforce a UTC time offset when converting an `OffsetDateTime` into a Header value

* Use the more readable version of `Duration::seconds(0)`, `Duration::zero()`

* Remove unneeded conversion of time::Duration to std::time::Duration

* Use `OffsetDateTime::as_seconds_f64` instead of manually calculating the amount of seconds from nanoseconds

* Replace a few additional instances of `Duration::seconds(0)` with `Duration::zero()`

* Truncate any nanoseconds from a supplied `Duration` within `Cookie::set_max_age` to ensure two Cookies with the same amount whole seconds equate to one another

* Fix the actix-http:🍪:do_not_panic_on_large_max_ages test

* Convert `Cookie::max_age` and `Cookie::expires` examples to `time` 0.2

Mainly minor  changes. Type inference can be used alongside the new
`time::parse` method, such that the type doesn't need to be specified.
This will be useful if a refactoring takes place that changes the type.
There are also new macros, which are used where possible.

One change that is not immediately obvious, in `HttpDate`, there was an
unnecessary conditional. As the time crate allows for negative durations
(and can perform arithmetic with such), the if/else can be removed
entirely.

Time v0.2.3 also has some bug fixes, which is why I am not using a more
general v0.2 in Cargo.toml.

v0.2.3 has been yanked, as it was backwards imcompatible. This version
reverts the breaking change, while still supporting rustc back to
1.34.0.

* Add missing `time::offset` macro import

* Fix type confusion when using `time::parse` followed by `using_offset`

* Update `time` to 0.2.5

* Update CHANGES.md

Co-authored-by: Jacob Pratt <the.z.cuber@gmail.com>
2020-01-28 20:44:22 +09:00
Kai Ren cdba30d45f Skip empty chucks for BodyStream and SizedStream (#1308)
* Skip empty chucks for BodyStream and SizedStream when streaming response (#1267)

* Fix tests to fail on previous implementation

Co-authored-by: Yuki Okushi <huyuumi.dev@gmail.com>
2020-01-28 18:28:09 +09:00
Aaron Hill 74dcc7366d Remove several uses of Pin::new_unchecked (#1294)
Most of the relevant struct already had a `#[pin_project]` attribute,
but it wasn't being used.

The remaining uses of `Pin::new_unchecked` all involve going from a
`&mut T` to a `Pin<&mut T>`, without directly observing a `Pin<&mut T>`
first. As such, they cannot be replaced by `pin_project`

Co-authored-by: Yuki Okushi <huyuumi.dev@gmail.com>
2020-01-28 12:35:51 +09:00
Maxim Vorobjov 8888520d83 Add benchmark for full stack request lifecycle (#1298)
* add benchmark for full stack request lifecycle

* add direct service benchmarks

* fix newline

* add cloneable service benchmarks

* remove cloneable bench experiments + cargo fmt

Co-authored-by: Yuki Okushi <huyuumi.dev@gmail.com>
2020-01-25 08:05:25 +09:00
Maxim Vorobjov 58844874a0 Fixing #1295 convert UnsafeCell to RefCell in CloneableService (#1303)
Co-authored-by: Yuki Okushi <huyuumi.dev@gmail.com>
2020-01-24 14:51:38 +09:00
Rob Ede a3287948d1 allow explicit SameSite=None cookies (#1282)
fixes #1035
2020-01-23 10:08:23 +09:00
linkmauve abb462ef85 Replace sha1 dependency with sha-1 (#1258)
* Replace sha1 dependency with sha-1

This other crate is being maintained, and it offers better performances
when using the `asm` feature (especially [on
AArch64](https://github.com/RustCrypto/hashes/pull/97)).

* Update CHANGES.md with the sha-1 migration

* Add a test for hash_key()
2020-01-11 02:34:31 +09:00
Nikolay Kim e66312b664 add extra constraints 2020-01-10 11:36:59 +06:00
linkmauve f5fd6bc49f Fix actix-http examples (#1259)
Fix actix-http examples
2020-01-07 00:15:04 +09:00
Nikolay Kim c7f3915779 update actix-service dep 2019-12-22 16:39:25 +04:00
Nikolay Kim 1d12ba9d5f Replace brotli with brotli2 #1224 2019-12-20 13:50:07 +06:00
Nikolay Kim 8c54054844 Use .advance() intead of .split_to() 2019-12-19 09:56:14 +06:00
Nikolay Kim 1732ae8c79 fix Bodyencoding trait usage 2019-12-18 09:30:14 +06:00
Rajasekharan Vengalil 3b860ebdc7 Fix poll_ready call for WebSockets upgrade (#1219)
* Fix poll_ready call for WebSockets upgrade

* Poll upgrade service from H1ServiceHandler too
2019-12-17 13:34:25 +06:00
Andrii Radyk 30dcaf9da0 fix deprecated Error::description (#1218) 2019-12-16 07:43:19 +06:00
Nikolay Kim cb705317b8 compile with default-features off 2019-12-15 13:28:54 +06:00
Nikolay Kim e8e0f98f96 fix docs.rs features list 2019-12-13 12:41:48 +06:00
Nikolay Kim fac6dec3c9 update deps 2019-12-13 12:36:15 +06:00
Nikolay Kim 3d64d565d9 fix warnings 2019-12-13 11:46:02 +06:00
Nikolay Kim c1deaaeb2f cleanup imports 2019-12-13 11:24:57 +06:00
Nikolay Kim b81417c2fa fix warnings 2019-12-13 10:59:02 +06:00
Nikolay Kim 4937c9f9c2 refactor http-test server 2019-12-12 23:08:38 +06:00
Nikolay Kim fa07415721 Replace flate2-xxx features with compress 2019-12-12 15:08:08 +06:00
Nikolay Kim b4b3350b3e Add websockets continuation frame support 2019-12-12 14:06:54 +06:00
0x1793d1 1b8d747937 Fix extra line feed (#1209) 2019-12-12 07:05:39 +06:00
Nikolay Kim 131c897099 upgrade to actix-net release 2019-12-11 19:20:20 +06:00
Nikolay Kim 5132257b0d Fix buffer remaining capacity calcualtion 2019-12-09 21:55:22 +06:00
Nikolay Kim 0c1f5f9edc Check Upgrade service readiness before calling it 2019-12-09 17:40:15 +06:00
Sameer Dhar e4382e4fc1 Fix broken docs (#1204)
Fixed un escaped brackets in lib.rs, and reflowed links to ConnectionInfo in app, config, and server.rs
2019-12-09 10:02:43 +06:00
Nikolay Kim a3ce371312 ws ping and pong uses bytes #1049 2019-12-09 07:01:22 +06:00
Nikolay Kim b92eafb839 prepare actix-http release 2019-12-08 20:15:51 +06:00
Nikolay Kim 1f3ffe38e8 update actix-service dep 2019-12-08 19:25:24 +06:00
Nikolay Kim 4a8a9ef405 update tests and clippy warnings 2019-12-08 12:31:16 +06:00
Nikolay Kim 6c9f9fff73 clippy warnings 2019-12-08 00:46:51 +06:00
Nikolay Kim 7ec5ca88a1 update changes 2019-12-07 22:01:55 +06:00
daxpedda e5f3d88a4e Switch brotli compressor to rust. (#1197)
* Switch to a rustified version of brotli.

* Some memory optimizations.

* Make brotli not optional anymore.
2019-12-07 21:55:41 +06:00
Nikolay Kim 0ba125444a Add impl ResponseBuilder for Error 2019-12-07 21:41:34 +06:00
daxpedda 4921243add Fix rustls build. (#1195) 2019-12-07 16:14:09 +06:00
Nikolay Kim 1729a52f8b prepare alpha.3 release 2019-12-07 13:00:03 +06:00
Nikolay Kim 205a964d8f upgrade to tokio 0.2 2019-12-05 23:35:43 +06:00
Nikolay Kim b45c6cd66b replace hashbrown with std hashmap 2019-12-04 18:33:43 +06:00
Nikolay Kim 14075ebf7f use released versions of actix-net 2019-12-02 23:33:39 +06:00
Nikolay Kim 068f047dd5 update service factory config 2019-12-02 21:37:13 +06:00
Nikolay Kim f4c01384ec update to latest actix-net 2019-12-02 17:33:11 +06:00
Nikolay Kim 56b9f11c98 disable rustls 2019-11-27 21:07:49 +06:00
Nikolay Kim f73f97353b refactor ResponseError trait 2019-11-26 16:07:39 +06:00
Nikolay Kim 4dc31aac93 use actix_rt::test for test setup 2019-11-26 11:25:50 +06:00
Nikolay Kim c1c44a7dd6 upgrade derive_more 2019-11-25 17:59:14 +06:00
Nikolay Kim 57981ca04a update tests to async handlers 2019-11-22 11:49:35 +06:00
Nikolay Kim 512dd2be63 disable rustls support 2019-11-22 07:01:05 +06:00
Nikolay Kim 8683ba8bb0 rename .to_async() to .to() 2019-11-21 21:36:35 +06:00
Nikolay Kim 69cadcdedb migrate actix-files 2019-11-21 16:02:17 +06:00
Nikolay Kim 3127dd4db6 migrate actix-web to std::future 2019-11-21 16:02:17 +06:00
Nikolay Kim d081e57316 fix h2 client send body 2019-11-21 16:02:17 +06:00
Nikolay Kim 1ffa7d18d3 drop unpin constraint 2019-11-21 16:02:17 +06:00
Nikolay Kim 687884fb94 update test-server tests 2019-11-21 16:02:17 +06:00
Nikolay Kim 5ab29b2e62 migrate awc and test-server to std::future 2019-11-21 16:02:17 +06:00
Nikolay Kim a6a2d2f444 update ssl impls 2019-11-21 16:02:17 +06:00
Nikolay Kim 9e95efcc16 migrate client to std::future 2019-11-21 16:02:17 +06:00
Nikolay Kim 8cba1170e6 make actix-http compile with std::future 2019-11-21 16:02:17 +06:00