Commit Graph

348 Commits

Author SHA1 Message Date
Sergio Benitez
1369dc47a3 Update 'atomic' and 'ubyte' dependencies. 2020-09-11 01:20:44 -07:00
Sergio Benitez
adbf1caab2 Migrate to upstream 'uncased'. 2020-09-11 01:13:55 -07:00
Sergio Benitez
f7eacb6a65 Tidy 'form_value_from_encoded_str' test. 2020-09-10 02:15:29 -07:00
lewis
53d13a309b Decode in 'FromFormValue' as needed by 'FromStr'.
Fixes #1425.
2020-09-10 02:07:54 -07:00
Jeb Rosen
f976c15c25 Update UI tests for latest nightly. 2020-09-06 18:34:24 -07:00
Jeb Rosen
dc2c6ecd8a Update UI tests for latest stable. 2020-08-31 18:51:38 -07:00
Sergio Benitez
52320020bc Use thread-safe 'CookieJar's.
The user-facing changes effected by this commit are:

  * The 'http::Cookies<'_>' guard is now '&http::CookieJar<'_>'.
  * The "one-at-a-time" jar restriction is no longer imposed.
  * 'CookieJar' retrieval methods return 'http::CookieCrumb'.
  * The 'private-cookies' feature is now called 'secrets'.
  * Docs flag private cookie methods with feature cfg.
  * Local, async request dispatching is never serialized.
  * 'Client::cookies()' returns the tracked 'CookieJar'.
  * 'LocalResponse::cookies()' returns a 'CookieJar'.
  * 'Response::cookies()' returns an 'impl Iterator'.
  * A path of '/' is set by default on all cookies.
  * 'SameSite=strict' is set by default on all cookies.
  * 'LocalRequest::cookies()' accepts any 'Cookie' iterator.
  * The 'Debug' impl for 'Request' prints the cookie jar.

Resolves #1332.
2020-08-16 02:19:45 -07:00
Sergio Benitez
549c9241c4 Require data limits on 'Data::open()'.
Closes #1325.
2020-08-06 02:46:04 -05:00
Sergio Benitez
45b4436ed3 Add default catchers: '#[catch(default)]'.
The bulk of the changes in this commit are for creating an
'ErrorHandler' trait that works like the 'Handler' trait, but for
errors. Furthermore, Rocket's default catcher now responds with a JSON
payload if the preferred 'Accept' media type is JSON.

This commit also fixes a bug in 'LocalRequest' where the internal
'Request' contained an correct 'URI'.
2020-07-30 01:55:41 -07:00
Sergio Benitez
e531770989 Make URI modifications to 'Route' codegen-safe.
This commit aims to make it impossible to modify a 'Route' structure in
a way that violates expectations of a code-generated 'Route'. It removes
'Route::set_uri()' in favor of 'Route::map_base()', which allows for
safe modifications of the route's base.

In a similar vain, this commit also includes the following changes:

  * 'Route::path()' was added to safely retrieve the route's 'path'.
  * The base of a 'Route' is underlined during launch printing.
  * 'Origin::into_normalized()' replaces 'Origin::to_normalized()'.

Fixes #1262.
2020-07-29 16:38:24 -07:00
Jonathan Dickinson
f3beb68491 Remove superfluous lifetimes in 'Fairing' methods. 2020-07-23 21:32:20 -07:00
Sergio Benitez
754b1e0e31 Panic if 'StaticFiles' directory doesn't exist. 2020-07-23 20:12:20 -07:00
Sergio Benitez
261cb400d1 Don't use managed state to thread 'Shutdown'. 2020-07-22 19:22:32 -07:00
Sergio Benitez
adc79016cd Rearrange top-level exports. Use '#[launch]'.
This commits makes the following high-level changes:

  * 'ShutdownHandle' is renamed to 'Shutdown'.
  * 'Rocket::shutdown_handle()' is renamed to 'Rocket::shutdown()'.
  * '#[launch]` is preferred to '#[rocket::launch]'.
  * Various docs phrasings are improved.
  * Fixed various broken links in docs.

This commits rearranges top-level exports as follows:

  * 'shutdown' module is no longer exported.
  * 'Shutdown' is exported from the crate root.
  * 'Outcome' is not longer exported from the root.
  * 'Handler', 'ErrorHandler' are no longer exported from the root.
2020-07-22 16:10:02 -07:00
Necmettin Karakaya
fde6eda915 Fix various typos throughout the codebase. 2020-07-22 12:56:01 -07:00
Jeb Rosen
8d779caa22 Note lower ranks are higher precedence in 'Route'.
Fixes #1360.
2020-07-22 12:28:56 -07:00
Sergio Benitez
ddfd73d6f3 Delete broken symlinks to 'update-references.sh'.
Fixes #1385.
2020-07-22 06:52:04 -07:00
Sergio Benitez
56a6172625 Enable compilation with stable Rust.
To the Rust teams, Rust's contributors, Rocket's contributors, the
entire Rust and Rocket communities, my colleagues at Stanford and
beyond, and Jeb: thank you all. Sincerely.

To the next ~4 years of Rocket!

Closes #19.
2020-07-21 16:30:45 -07:00
Sergio Benitez
b47d1b8f0f Rework docs for stable and async support. 2020-07-21 16:15:13 -07:00
Sergio Benitez
cd7e99a535 Use 'bencher' for benchmarks on stable. 2020-07-21 15:31:44 -07:00
Sergio Benitez
9a2149b43d Test guide and README using stable 'doc_comment'. 2020-07-21 15:31:44 -07:00
Sergio Benitez
67efe143c5 Improve diagnostics, especially on stable. 2020-07-21 15:31:42 -07:00
Sergio Benitez
1858403203 Implement codegen testing on stable.
This commits migrates to 'trybuild' from 'compiletest' for codegen
diagnostic testing.
2020-07-21 15:11:07 -07:00
Sergio Benitez
95a4b442cc Update Pear to 0.2. 2020-07-21 15:11:07 -07:00
Jeb Rosen
27b26188c4 Update 'toml' to '0.5'. 2020-07-21 15:11:07 -07:00
Jeb Rosen
fb42bf9ee2 Upgrade 'tokio-rustls' to 0.14. 2020-07-21 10:54:07 -07:00
Jakub Wieczorek
6f1cefff10 Upgrade 'percent-encoding' to 2.
Co-authored-by: Jeb Rosen <jeb@jebrosen.com>
2020-07-21 10:54:07 -07:00
Jeb Rosen
7f276eb2fc Update 'devise' to the latest commit. 2020-07-20 23:26:36 -07:00
Sergio Benitez
0909ba2ef6 Only enable testing features on 'cfg(test)'. 2020-07-16 05:49:38 -07:00
Sergio Benitez
3f2b8f6006 Remove 'proc_macro' features. 2020-07-16 05:46:39 -07:00
Sergio Benitez
7bcf82a199 Improve catcher mismatched type errors. 2020-07-14 02:48:46 -07:00
Sergio Benitez
dfca18d307 Generate 'uri!' macro names independently of span.
Prior to this commit, codegen used 'Span' information to generate a
unique id for a given route. This commit changes the id generation to
instead use 1) the route's name and path, 2) a an per-generation
atomically increasing ID, and 3) the ids of the process/thread the
proc-macro is running in. Together, these values should provide a unique
id for a given route, even in the face of the reused processes and
threads, while also removing the dependence on unstable Span features.

Fixes #1373.
2020-07-14 00:44:59 -07:00
Sergio Benitez
816b8c44ab Ignore 'snake_case' warnings for 'tmp' variables. 2020-07-14 00:43:48 -07:00
Sergio Benitez
a87e3ad9f5 Remove superfluous empty lines. 2020-07-12 02:38:28 -07:00
Sergio Benitez
33e95f4900 Rename 'FromDataSimple' to 'FromData'. Make async.
The 'FromData' trait becomes 'FromTransformedData'.
2020-07-12 02:23:00 -07:00
Sergio Benitez
f4c82d7ffe Remove unnecessary 'dev-dependencies'. 2020-07-11 11:27:23 -07:00
Sergio Benitez
62355b424f Remove use of stable 'proc_macro_hygiene' feature. 2020-07-11 10:48:08 -07:00
Sergio Benitez
08b34e8263 Fix and re-enable UI tests. 2020-07-11 09:24:30 -07:00
Sergio Benitez
832408ea9b Add example requiring async testing. 2020-07-11 09:24:30 -07:00
Jeb Rosen
06975bfaea Use the blocking testing API everywhere.
Co-authored-by: Sergio Benitez <sb@sergio.bz>
2020-07-11 09:24:30 -07:00
Sergio Benitez
6482fa2fba Rework 'local' module. Add 'LocalResponse' methods.
This completes the 'local' blocking client implementation.
2020-07-11 09:24:30 -07:00
Jeb Rosen
050a2c6461 Document new 'local' structures. 2020-07-11 09:24:30 -07:00
Sergio Benitez
03127f4dae Add blocking variant of 'local'.
This commit adds the 'local::blocking' module and moves the existing
asynchronous testing to 'local::asynchronous'. It also includes several
changes to improve the local API, bringing it to parity (and beyond)
with master. These changes are:

  * 'LocalRequest' implements 'Clone'.
  * 'LocalResponse' doesn't implement 'DerefMut<Target=Response>'.
    Instead, direct methods on the type, such as 'into_string()', can
    be used to read the 'Response'.
  * 'Response::body()' returns an '&ResponseBody' as opposed to '&mut
    ResponseBody', which is returned by a new 'Response::body_mut()'.
  * '&ResponseBody' implements 'known_size()` to retrieve a body's size,
    if it is known.

Co-authored-by: Jeb Rosen <jeb@jebrosen.com>
2020-07-11 09:24:30 -07:00
Sergio Benitez
824de061c3 Enable configurable 'ctrl-c' shutdown by default.
This removes the 'ctrl_c_shutdown' feature opting instead for a 'ctrlc'
configuration option. To avoid further merge conflicts with the master
branch, the option is currently read as an extra.

Co-authored-by: Jeb Rosen <jeb@jebrosen.com>
2020-07-11 09:24:30 -07:00
Sergio Benitez
9277ddafdf Swap 'Rocket' manually without using 'replace_with'. 2020-07-11 09:24:30 -07:00
Sergio Benitez
3ced188f7d Use 'ref-cast' for safer transparent casting. 2020-07-11 09:24:30 -07:00
Sergio Benitez
d89c7024ed Replace 'Manifest' with 'Cargo'.
This is largely an internal change. Prior to this commit, the 'Manifest'
type, now replaced with the 'Cargo' type, robbed responsibility from the
core 'Rocket' type. This new construction restores the previous
responsibility and makes it clear that 'Cargo' is _only_ for freezing,
and representing the stability of, Rocket's internal state.
2020-07-11 09:24:30 -07:00
Sergio Benitez
dd5b518cc2 Ignore 'unused_imports' warning on cfg-based 'FutureExt'. 2020-07-11 09:24:30 -07:00
Sergio Benitez
1704ff7743 Asyncify 'Handler'. Rename 'ErrorHandlerFuture' to 'CatcherFuture'. 2020-07-11 09:24:30 -07:00
Sergio Benitez
f7cd455558 Make 'NamedFile' async. Fix 'Handler' trait.
Previously, 'NamedFile::open()' called a synchronous I/O method. This
commit changes it to instead use tokio's 'File' for async I/O.

To allow this to change, the 'Handler' trait was fixed to enforce that
the lifetime of '&self', the reference to the handler, outlives the
incoming request. As a result, futures returned from a handler can hold
a reference to 'self'.
2020-07-11 09:24:30 -07:00