Commit Graph

1360 Commits

Author SHA1 Message Date
Scott McMurray f2a56f4222 Fix 'Try' 'impl FromResidual<Result> for Outcome'. 2021-05-19 10:04:31 -07:00
Sergio Benitez 018b57ead1 Use '-Zrustdoc-map' to fill in external doc URLs. 2021-05-18 21:35:16 -07:00
Sergio Benitez 7adfbd5a1e New version: 0.4.8. 2021-05-18 21:18:12 -07:00
Sergio Benitez 6850f95115 Update 'base64' to 0.13'. 2021-05-18 21:10:37 -07:00
Sergio Benitez 425f741b87 Update 'Try' impl, codegen for nightly-2021-05-18.
Minimum nightly is now '2021-05-18'.
2021-05-18 20:59:11 -07:00
Sergio Benitez f939439911 Use stable 'parking_lot::const_mutex()' in todo. 2021-05-18 20:59:11 -07:00
Sergio Benitez 21a396c10d Add '.cargo/' to gitignore. 2021-05-18 20:35:17 -07:00
Brendon Federko 93e88b019b Enable 'std' 'indexmap' feature.
Fixes #1548.
2021-04-16 21:55:58 -07:00
Sergio Benitez 40f155f820 Fix 0.4.7 release year in CHANGELOG. 2021-02-10 16:43:30 -08:00
Sergio Benitez b67bd8be90 New version: 0.4.7. 2021-02-09 17:41:40 -08:00
Sergio Benitez 2059a626ff Update UI tests for latest nightly. 2021-02-09 17:35:15 -08:00
Sergio Benitez b53a906a8e Fix soundness issue: make 'Formatter' panic-safe.
Fixes #1534.
2021-02-09 17:28:42 -08:00
Sergio Benitez b4fadae53d New version: 0.4.6. 2020-11-09 23:22:43 -08:00
Sergio Benitez 11ec95ef8f Update broken doc links in contrib. 2020-11-09 23:19:41 -08:00
Sergio Benitez 08bf1c5bdb Update scripts. 2020-11-09 23:19:41 -08:00
Sergio Benitez 86bd7c1008 Allow read/write timeouts to be configured.
Resolves #1472.
2020-11-09 14:52:35 -08:00
Sergio Benitez 3970783d06 Fix SSE example, clean-up SSE related code.
Also updates UI tests for latest nightly.
2020-10-29 23:37:43 -07:00
Ian Jackson c24a96308b Add support for immediate chunk flushing, SSE.
Problem:

To support Server-Side Events (SSE, aka JS EventSource) it is
necessary for the server to keep open an HTTP request and dribble out
data (the event stream) as it is generated.

Currently, Rocket handles this poorly.  It likes to fill in complete
chunks.  Also there is no way to force a flush of the underlying
stream: in particular, there is a BufWriter underneath hyper.  hyper
would honour a flush request, but there is no way to send one.

Options:

Ideally the code which is producing the data would be able to
explicitly designate when a flush should occur.  Certainly it would
not be acceptable to flush all the time for all readers.

1. Invent a new kind of Body (UnbufferedChunked) which translates the
data from each Read::read() call into a single call to the stream
write, and which always flushes.  This would be a seriously invasive
change.  And it would mean that SSE systems with fast event streams
might work poorly.

2. Invent a new kind of Body which doesn't use Read at all, and
instead has a more sophisticated API.  This would be super-invasive
and heavyweight.

3. Find a way to encode the necessary information in the Read trait
protocol.

Chosen solution:

It turns out that option 3 is quite easy.  The read() call can return
an io::Error.  There are at least some errors that clearly ought not
to occur here.  An obvious one is ErrorKind::WouldBlock.

Rocket expects the reader to block.  WouldBlock is only applicable to
nonblocking objects.  And indeed the reader will generally want to
return it (once) when it is about to block.

We have the Stream treat io::Error with ErrorKind::WouldBlock, from
its reader, as a request to flush.  There are two effects: we stop
trying to accumulate a full chunk, and we issue a flush call to the
underlying writer (which, eventually, makes it all the way down into
hyper and BufWriter).

Implementation:

We provide a method ReadExt::read_max_wfs which is like read_max but
which handles the WouldBlock case specially.  It tells its caller
whether a flush was wanted.

This is implemented by adding a new code to read_max_internal.  with a
boolean to control it.  This seemed better than inventing a trait or
something.  (The other read_max call site is reading http headers in
data.rs, and I think it wants to tread WouldBlock as an error.)

Risks and downsides:

Obviously this ad-hoc extension to the Read protocol is not
particularly pretty.  At least, people who aren't doing SSE (or
similar) won't need it and can ignore it.

If for some reason the data source is actually nonblocking, this new
arrangement would spin, rather than calling the situation a fatal
error.  This possibility seems fairly remote, in production settings
at least.  To migitate this it might be possible for the loop in
Rocket::issue_response to bomb out if it notices it is sending lots of
consecutive empty chunks.

It is possible that async Rocket will want to take a different
approach entirely.  But it will definitely need to solve this problem
somehow, and naively it seems like the obvious transformation to eg
the Tokio read trait would have the same API limitation and admit the
same solution.  (Having a flush occur every time the body stream
future returns Pending would not be good for performance, I think.)
2020-10-29 23:37:36 -07:00
Sergio Benitez 7b1995c84a For install Rust nightly in CI script. 2020-09-12 03:21:49 -07:00
Jeb Rosen b109d151a6 Fix library versions in database contrib docs. 2020-09-12 03:11:51 -07:00
Sergio Benitez 6f5725b83d Update source code idiomacy, clearing warnings. 2020-09-12 03:10:27 -07:00
Sergio Benitez 894fe3c709 Fix benchmark features. 2020-09-12 02:49:51 -07:00
Sergio Benitez 559e64cc1f Migrate to 'trybuild' for UI tests. 2020-09-12 02:43:49 -07:00
Sergio Benitez 2162a72114 Set reasonable read/write timeouts. 2020-09-12 02:32:09 -07:00
Sergio Benitez 4683407f59 New version: 0.4.5. 2020-05-30 14:29:06 -07:00
Nia Watts 86e98b3ad8 Fix typo in 'Query' documentation: 'mplementation' -> 'implementation'. 2020-05-30 14:01:32 -07:00
Sergio Benitez 278233fe1a Require 'cookie' '0.11.3'. 2020-05-30 01:44:03 -07:00
Sergio Benitez e75e227afc Improve docs for 'Options::NormalizeDirs'. 2020-05-30 01:40:39 -07:00
Sergio Benitez 883388634e Add 'Options::NormalizeDirs' to 'StaticFiles'.
Closes #1198.

Co-authored-by: Keith Wansbrough <keithw@lochan.org>
2020-05-30 01:09:20 -07:00
Sergio Benitez 6cb0521ac9 Add 'handler::Outcome::from_or_forward()'. 2020-05-30 00:59:21 -07:00
Sergio Benitez c8ee13b220 Add 'Origin::map_path()' method. 2020-05-30 00:48:23 -07:00
Sergio Benitez d195944645 Update 'parking_lot' dependency. 2020-05-29 01:53:06 -07:00
Sergio Benitez 7739c0e977 Update 'base64' to '0.12'. 2020-05-29 01:53:06 -07:00
Sergio Benitez 89150f9b81 Fix 'LocalRequest::clone()' soundness issue.
The existing implementation of 'LocalRequest::clone()' mistakenly copied
the internal 'Request' pointer from the existing 'LocalRequest' to the
cloned 'LocalRequest'. This resulted in an aliased '*mut Request'
pointer, a clear soundness issue. The fix in this commit is to clone the
internal 'Request', replacing the internal pointer with the newly cloned
'Request' when producing the cloned 'LocalRequest'. A fix that removes
all 'unsafe' code should be explored.

Fixes #1312.
2020-05-29 01:53:06 -07:00
Jeb Rosen ccb5eb1d4f Update UI tests for latest nightly. 2020-05-29 01:53:06 -07:00
Sergio Benitez 376f741338 Properly delimit length and name in flash cookies.
Fixes #1263.
2020-05-29 01:53:06 -07:00
benjaminbecker af5ee6dd15 Fix typo in configuration guide: 'AssertsDir' -> 'AssetsDir'. 2020-05-29 01:53:06 -07:00
Thiago Veronezi 3d31dad760 Fix typo in 'State' documentation: missing backtick. 2020-05-29 01:53:06 -07:00
Sorin Davidoi d265ca70bf Improve accessibility of default error HTML. 2020-05-29 01:53:06 -07:00
Sergio Benitez 807e3b8d85 New version: 0.4.4. 2020-03-09 02:17:21 -07:00
Sergio Benitez d559f09abc Update UI tests for latest nightly. 2020-03-09 02:08:50 -07:00
Sergio Benitez 635a4bddba Fix more broken links. 2020-03-09 02:04:03 -07:00
Sergio Benitez cba00ec66a Fix an array of broken doc links. 2020-03-09 01:12:43 -07:00
Sergio Benitez 0ee3205a68 Remove double semicolons; silence test warnings. 2020-03-08 19:18:41 -07:00
Jeb Rosen 2b9c4197d8 Remove [target.'cfg(debug_assertions)'.dependencies] in contrib Cargo.toml.
This is not supported and is the same as putting the contents in
[dependencies] anyway. It became a warning in rust-lang/cargo#7660.

Backport of 4151cd46db.
2020-03-08 12:49:23 +01:00
ollipa 7446707659 Fix 0.4.3 release year in CHANGELOG. 2020-03-01 14:36:45 -08:00
Sergio Benitez 60623e8544 Fix UI tests for macOS CI. 2020-02-29 18:44:46 -08:00
Sergio Benitez b3d65b0ad2 New version: 0.4.3. 2020-02-29 18:19:02 -08:00
Sergio Benitez e2213d0f06 Prefix release codenames with 'v'. 2020-02-29 18:18:50 -08:00
Sergio Benitez 90eaad852c Deprecate 'Result' specialization. Add 'Debug' responder. 2020-02-29 17:47:57 -08:00