Commit Graph

395 Commits

Author SHA1 Message Date
Sergio Benitez
0af25bfb6d Move derive attribute after derive. 2021-02-09 17:17:26 -08:00
Sergio Benitez
e325e2fce4 Fix soundness issue: make 'Formatter' panic-safe.
Fixes #1534.
2021-02-09 16:58:34 -08:00
Sergio Benitez
c24f15c18f Add regression test for #1503.
Closes #1503.
2021-01-14 15:15:57 -08:00
Sergio Benitez
407e346a6a Clean up 'on_launch_fairing_can_inspect_port' test. 2021-01-13 17:20:44 -08:00
Filip Gospodinov
48fd83a31d Run launch fairings after effective port is known. 2021-01-13 17:20:33 -08:00
Sergio Benitez
43ade920c5 Warn when deprecated profiles are set. 2021-01-13 16:21:36 -08:00
Sergio Benitez
28976a5bd3 Preserve 'secret_key' in 'Config' provider data.
Also fixes emission of 'secret_key' warnings when 'secrets' feature is
disabled.

Resolves #1505.
Fixes #1510.
2021-01-13 16:01:39 -08:00
Jeb Rosen
92af8fca72 Update to 'tokio' 1.0, 'hyper' 0.14. 2021-01-13 15:22:16 -08:00
Sergio Benitez
031948c1da Remove superfluous semicolons. 2021-01-13 14:30:08 -08:00
Brendon Federko
cb33429ce4 Enable 'std' 'indexmap' feature. 2021-01-12 14:52:37 -08:00
Brendon Federko
e68a951a54 Upodate tests for latest stable. 2021-01-12 14:52:34 -08:00
Sergio Benitez
9671115796 Use 'workers' value from 'Config::figment()'.
This commit also improves config pretty-printing and warning messages.
It also fixes an issue that resulted in config value deprecation
warnings not being emitted. The 'workers' value is now a 'usize', not a
'u16'; contrib pool sizes now default to 'workers * 2'.

Closes #1470.
2020-12-24 15:58:48 -08:00
Jeb Rosen
1f1f44f336 Update UI tests for latest stable. 2020-11-21 12:42:57 -08:00
Sergio Benitez
fa77435187 Bust cache on 'Request::{add,replace}_header()'.
Also changes 'Header::name()' to return '&UncasedStr'.

Resolves #518.
2020-11-05 21:03:58 -08:00
Sergio Benitez
86ff66a69c Streamline raw identifier support in codegen. 2020-11-03 12:07:23 -08:00
Jeb Rosen
97f6bc5dc0 Support raw identifiers in forms, routes, uri.
Resolves #881.
2020-11-03 01:42:37 -08:00
Sergio Benitez
b5e4dded8a Accept browser-sent unencoded query characters.
Closes #941.

Co-authored-by: Vladimir Ignatev <ya.na.pochte@gmail.com>
2020-11-02 15:08:33 -08:00
Sergio Benitez
949bb01e2d Generate path encoding set using 'const fn'.
Co-authored-by: Jakub Wieczorek <jakub.adam.wieczorek@gmail.com>
2020-11-01 21:26:31 -08:00
Sergio Benitez
337e8843a4 Use 'Option', 'Result' directly in 'uri!' query.
Prior to this commit, the conversion 'T -> Option<T>' was applied in
both the path and query parts of a URI in the 'uri' macro via the
'FromUriParam' trait with no implementation for 'Option<T>' directly.
This meant that it was impossible to directly render an 'Option<T>'.
This was exactly desired for the path part, where rendering a 'None'
would yield an incorrect URI, but the restriction was too strict for the
query part, where a 'None' is entirely valid. This commit makes changes
the conversion so that it only applied to path parts and adds the
identity conversions for 'Option<T>' and 'Result<T, E>' for query parts.

The side effect is a breaking change: due to conflicting impls, the 'T'
to 'Option<T>' conversion was removed for query parts. Thus, all 'uri!'
query route arguments of type 'Option' or 'Result' must now be wrapped
in 'Some' or 'Ok'. Due to new 'Option<T> <-> Result<T, E>' conversions,
either 'Some' _and_ 'Ok' work in both contexts.

Closes #1420.
2020-11-01 10:30:30 -08:00
Sergio Benitez
edc91f65b7 Mimic Rocket's config in custom providers example. 2020-10-30 03:08:26 -07:00
Sergio Benitez
55b651bd70 Use 'rocket::custom()' for 'State' tests. 2020-10-30 02:49:00 -07:00
Jonty
b7565172eb Impl 'Clone' for 'State'.
Resolves #1411.
2020-10-30 02:16:24 -07:00
Sergio Benitez
a6f5a63535 Add tests for ignored parameters '<_>'.
Co-authored-by: timokoesters <timo@koesters.xyz>
2020-10-30 00:47:41 -07:00
Sergio Benitez
8e8fb4cae8 Allow ignored route path segments.
Co-authored-by: timokoesters <timo@koesters.xyz>
2020-10-30 00:06:39 -07:00
Sergio Benitez
23738446f0 Impl 'std::error::Error' for 'Error'.
Resolves #1460.
2020-10-27 16:04:25 -07:00
Sergio Benitez
8570afff3e Use threaded scheduler in tests.
This prevents async I/O timeouts in attach fairings.

Co-authored-by: Jeb Rosen <jeb@jebrosen.com>
2020-10-26 13:29:36 -07:00
Sergio Benitez
09f0087034 Split server parts of 'Rocket' into 'server.rs'. 2020-10-22 18:00:07 -07:00
Sergio Benitez
198b6f0e97 Fix various broken rustdoc links. 2020-10-22 03:53:07 -07:00
Sergio Benitez
08510302da Add 'Rocket::catchers()', rearrange other getters. 2020-10-22 03:41:02 -07:00
Sergio Benitez
ec9b5816a8 Remove 'rocket::inspect()', 'Cargo'.
This commit reverts most of dea940c7 and d89c7024. The "fix" is to run
attach fairings on a new thread. If a runtime is already running, it is
used. Otherwise, the future is executed in a single-threaded executor.
2020-10-22 03:27:04 -07:00
Sergio Benitez
17fd7f4286 Update minimum rustc to 1.46. 2020-10-21 19:56:12 -07:00
Sergio Benitez
bbfe2ba5cc Point all docs and doc links to 'master' branch. 2020-10-21 04:54:24 -07:00
George Cheng
0673986c32 Impl 'FromRequest' for 'IpAddr'.
Closes #1414.
2020-10-20 20:51:26 -07:00
ThouCheese
080d586a35 Impl 'DerefMut' for 'Form', 'LenientForm'. 2020-10-20 20:45:43 -07:00
est31
b18cd6460e Add AVIF (image/avif) as a known media type. 2020-10-20 20:40:18 -07:00
Sergio Benitez
730a2dcdbe Implement 'Serialize' for 'Flash'.
Resolves #184.
2020-10-20 20:29:55 -07:00
Sergio Benitez
7337321efb Take '&mut Data' in 'on_request' fairings.
Resolves #1438.
2020-10-20 20:22:32 -07:00
Sergio Benitez
1fb061496d Revamp configuration.
This commit completely overhauls Rocket's configuration systems, basing
it on the new Figment library. It includes many breaking changes
pertaining to configuration. They are:

  * "Environments" are replaced by "profiles".
  * 'ROCKET_PROFILE' takes the place of 'ROCKET_ENV'.
  * Profile names are now arbitrary, but 'debug' and 'release' are given
    special treatment as default profiles for the debug and release
    compilation profiles.
  * A 'default' profile now sits along-side the meta 'global' profile.
  * The concept of "extras" is no longer present; users can extract any
    values they want from the configured 'Figment'.
  * The 'Poolable' trait takes an '&Config'.
  * The 'secrets' feature is disabled by default.
  * It is a hard error if 'secrets' is enabled under the 'release'
    profile and no 'secret_key' is configured.
  * 'ConfigBuilder' no longer exists: all fields of 'Config' are public
    with public constructors for each type.
  * 'keep_alive' is disabled with '0', not 'false' or 'off'.
  * Inlined error variants into the 'Error' structure.
  * 'LoggingLevel' is now 'LogLevel'.
  * Limits can now be specified in SI units: "1 MiB".

The summary of other changes are:

  * The default config file can be configured with 'ROCKET_CONFIG'.
  * HTTP/1 and HTTP/2 keep-alive configuration is restored.
  * 'ctrlc' is now a recognized config option.
  * 'serde' is now a core dependency.
  * TLS misconfiguration errors are improved.
  * Several example use '_' as the return type of '#[launch]' fns.
  * 'AdHoc::config()' was added for simple config extraction.
  * Added more documentation for using 'Limits'.
  * Launch information is no longer treated specially.
  * The configuration guide was rewritten.

Resolves #852.
Resolves #209.
Closes #1404.
Closes #652.
2020-10-20 19:21:56 -07:00
Sergio Benitez
8da034ab83 Update 'devise'. 2020-10-15 01:01:30 -07:00
Sergio Benitez
5615767ca6 Add proper 'cfg' to 'get_private_pending()'. 2020-10-15 00:46:30 -07:00
Sergio Benitez
5cf249581f Add 'const' constructor for 'MediaType'. 2020-10-14 23:54:37 -07:00
Sergio Benitez
079e458b62 Add (un)tracked 'Client' integration tests. 2020-10-14 21:47:42 -07:00
Sergio Benitez
5d9035ddc1 Keep an op-log for sync 'CookieJar'.
In brief, this commit:

  * Updates to the latest upstream 'cookie', fixing a memory leak.
  * Make changes to 'CookieJar' observable only through 'pending()'.
  * Deprecates 'Client::new()' in favor of 'Client::tracked()'.
  * Makes 'dispatch()' on tracked 'Client's synchronize on cookies.
  * Makes 'Client::untracked()' actually untracked.

This commit updates to the latest 'cookie' which removes support for
'Sync' cookie jars. Instead of relying on 'cookie', this commit
implements an op-log based 'CookieJar' which internally keeps track of
changes. The API is such that changes are only observable through
specialized '_pending()' methods.
2020-10-14 21:37:16 -07:00
Sergio Benitez
2f330d2967 Allow return type of '#[launch]' fn to be elided. 2020-10-12 22:32:02 -07:00
Sergio Benitez
092e03f720 Generate a proxy structure for better namespacing.
Prior to this commit, it was impossible to 'use' a route from a separate
namespace for use in a 'routes!' macro. Naturally, this was a common
source of confusion amongst users. This commit obviates this deficiency
by generating a "proxy" structure that can be imported and converted
into a 'Route'/'Catcher' or their static variants.

This change is largely backwards compatible but can break existing code
when routes are named identically to other types in the namespace.
2020-10-12 22:11:44 -07:00
Edwin Svensson
29f4726127 Fix typo in 'Form::into_inner' docs: unclosed codeblock. 2020-10-11 12:49:18 -07:00
Jeb Rosen
83a7fc48d2 Update UI tests for latest nightly. 2020-10-11 12:21:45 -07:00
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