Commit Graph

144 Commits

Author SHA1 Message Date
Sergio Benitez
08e5b6dd0d New version: 0.4.10. 2021-05-21 23:16:16 -07:00
Sergio Benitez
aabd886388 New version: 0.4.9. 2021-05-19 10:21:05 -07:00
Scott McMurray
f2a56f4222 Fix 'Try' 'impl FromResidual<Result> for Outcome'. 2021-05-19 10:04:31 -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
b67bd8be90 New version: 0.4.7. 2021-02-09 17:41:40 -08:00
Sergio Benitez
b4fadae53d New version: 0.4.6. 2020-11-09 23:22:43 -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
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
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
6cb0521ac9 Add 'handler::Outcome::from_or_forward()'. 2020-05-30 00:59:21 -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
Sergio Benitez
376f741338 Properly delimit length and name in flash cookies.
Fixes #1263.
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
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
b3d65b0ad2 New version: 0.4.3. 2020-02-29 18:19:02 -08:00
Sergio Benitez
90eaad852c Deprecate 'Result' specialization. Add 'Debug' responder. 2020-02-29 17:47:57 -08:00
Sergio Benitez
436a5aad57 Deprecate 'Result<T, E>, E: !Responder' responder. 2020-02-29 17:47:45 -08:00
Sergio Benitez
ff535c2ff9 Inline macro docs into core crate. 2020-02-27 18:42:28 -08:00
Dmitry Murzin
40f267c580 Implement 'FromParam' for 'NonZero*' types. 2020-02-27 18:20:01 -08:00
A. L
25c2f62850 Add additional Responder wrappers for some common HTTP status codes:
* 204 NoContent
* 401 Unauthorized
* 403 Forbidden
* 409 Conflict
2020-02-27 16:14:27 -08:00
Jacob Pratt
a1cca97587 Abide by formatting in 'Debug' implementations. 2020-02-27 16:04:36 -08:00
Sergio Benitez
60cba26f65 Fix guide examples for 0.4. 2020-02-27 15:35:56 -08:00
Sergio Benitez
4618bd0a5e Test all guide code examples.
Every code example is now fully runnable and testable. As a result, all
examples are now tested and include imports. Relevant imports are shown
by default. Code examples can be expanded to show all imports.

Fixes #432.
2020-02-27 14:43:06 -08:00
Sergio Benitez
0c56ecc181 Set cookies even on error responses.
Fixes #1213.
2020-02-09 01:53:05 -08:00
Sergio Benitez
35753c4d53 Fix tests for Windows. 2019-07-06 01:15:47 -07:00
Sergio Benitez
2d4dc5ae58 New version: 0.4.2. 2019-06-28 17:50:57 -07:00
Thomas Lent
b00423d7ac Fix type in 'Data' rustdocs: 'T' -> 'DataGuard'. 2019-06-28 12:20:39 -07:00
Sergio Benitez
2d4eec8f7e Update 'version_check' to 0.9. 2019-06-28 12:17:28 -07:00
jeb
8e7100f8f7 Reexport derive macros alongside derived traits. 2019-06-28 12:11:18 -07:00
Jacob Pratt
3e3fe56e6a Remove stabilized feature gates.
* try_from
* transpose_result
2019-06-28 12:08:49 -07:00
Sergio Benitez
dd06d7ba80 Clean up 'AdHoc' fairing implementation. 2019-06-28 12:08:49 -07:00
Konrad Borowski
8574dbf841 Replace uses of FnBox; Box<dyn FnOnce> now implements FnOnce. 2019-06-28 12:06:10 -07:00
Sergio Benitez
f1f09f17ca New version: 0.4.1. 2019-05-11 16:51:38 -07:00
Richard Petrie
2cb35e2544 Replace deprecated 'isatty' with 'atty'. 2019-05-10 19:50:58 -07:00
Sergio Benitez
82da917055 Clarify defaults in 'Config' documentation. 2019-05-10 19:50:58 -07:00
Sergio Benitez
9dce86744c Clean up 'Server' header commentary. 2019-05-09 09:11:51 -07:00
Sergio Benitez
cb359fe38b Clean up 'conditionally-set-server-header' test. 2019-05-09 09:11:51 -07:00
lu4nm3
0a068b0dd6 Set default 'Server' header only if it isn't set.
Closes #996.
2019-05-09 09:11:51 -07:00
Sergio Benitez
de9a98edd2 Update 'Rocket::custom()' docs to match signature.
Resolves #910.
2019-02-06 17:18:53 -08:00