Commit Graph

587 Commits

Author SHA1 Message Date
Sergio Benitez
fe59a7fe38 Use better types for 'Error' associated types. 2018-08-10 04:42:30 -07:00
kryptan
d9bfc9b104 Implement 'Responder' for '&[u8]'. 2018-08-07 23:58:54 -07:00
Sergio Benitez
41f0614b14 Update request-local state documentation. 2018-08-07 23:16:16 -07:00
jeb
d1cfdbaa8e Add documentation and examples for request-local state.
Closes #654.
2018-08-07 19:40:30 -07:00
Marc Mettke
cd776d5b6a Add 'and_then', 'failure_then', and 'forward_then' methods to 'Outcome'. 2018-08-07 18:55:04 -06:00
Sergio Benitez
d7f6d82fe4 Implement 'FromForm[Value]', 'Responder' proc-macro derives.
This completes the migration of custom derives to proc-macros, removing
the need for the `custom_derive` feature in consumer code. This commit
also includes documentation, unit tests, and compile UI tests for each
of the derives.

Additionally, this commit improves the existing `FromForm` and
`FromFormValue` derives. The generated code for `FromForm` now returns
an error value indicating the error condition. The `FromFormValue`
derive now accepts a `form` attribute on variants for specifying the
exact value string to match against.

Closes #590.
Closes #670.
2018-08-06 19:58:07 -07:00
Sergio Benitez
b0f86dcba0 Fix URI normalization checks in 'Rocket::mount()'. 2018-07-29 18:40:24 -07:00
Sergio Benitez
56c6a96f6a Overhaul URI types.
This is fairly large commit with several entangled logical changes.

The primary change in this commit is to completely overhaul how URI
handling in Rocket works. Prior to this commit, the `Uri` type acted as
an origin API. Its parser was minimal and lenient, allowing URIs that
were invalid according to RFC 7230. By contrast, the new `Uri` type
brings with it a strict RFC 7230 compliant parser. The `Uri` type now
represents any kind of valid URI, not simply `Origin` types. Three new
URI types were introduced:

  * `Origin` - represents valid origin URIs
  * `Absolute` - represents valid absolute URIs
  * `Authority` - represents valid authority URIs

The `Origin` type replaces `Uri` in many cases:

  * As fields and method inputs of `Route`
  * The `&Uri` request guard is now `&Origin`
  * The `uri!` macro produces an `Origin` instead of a `Uri`

The strict nature of URI parsing cascaded into the following changes:

  * Several `Route` methods now `panic!` on invalid URIs
  * The `Rocket::mount()` method is (correctly) stricter with URIs
  * The `Redirect` constructors take a `TryInto<Uri>` type
  * Dispatching of a `LocalRequest` correctly validates URIs

Overall, URIs are now properly and uniformly handled throughout Rocket's
codebase, resulting in a more reliable and correct system.

In addition to these URI changes, the following changes are also part of
this commit:

  * The `LocalRequest::cloned_dispatch()` method was removed in favor of
    chaining `.clone().dispatch()`.
  * The entire Rocket codebase uses `crate` instead of `pub(crate)` as a
    visibility modifier.
  * Rocket uses the `crate_visibility_modifier` and `try_from` features.

A note on unsafety: this commit introduces many uses of `unsafe` in the
URI parser. All of these uses are a result of unsafely transforming byte
slices (`&[u8]` or similar) into strings (`&str`). The parser ensures
that these casts are safe, but of course, we must label their use
`unsafe`. The parser was written to be as generic and efficient as
possible and thus can parse directly from byte sources. Rocket, however,
does not make use of this fact and so would be able to remove all uses
of `unsafe` by parsing from an existing `&str`. This should be
considered in the future.

Fixes #443.
Resolves #263.
2018-07-29 00:17:33 -07:00
Sergio Benitez
c04655f290 Remove unnecessary code in codegen_next. 2018-07-27 21:03:33 -07:00
jeb
706cd32053 Use absolute paths in 'FromFormValue' derive.
This resolves a warning introduced in rust-lang/rust#51952 that will
eventually become a hard error, the latter of which is being tracked
in rust-lang/rust#50504.
2018-07-25 15:55:41 -07:00
Sean Stangl
a7cc5542ab Fix various clippy warnings in core and codegen. 2018-07-25 15:28:35 -07:00
Sergio Benitez
aaad4f5c57 Remove use of 'unsafe' in 'Fairings'. 2018-07-22 22:00:20 -07:00
Sergio Benitez
cee3bbca30 Use git version of compiletest while release is broken. 2018-07-22 21:59:40 -07:00
Sergio Benitez
e25a82b14b Update dependencies for ring 0.13. 2018-07-22 21:59:40 -07:00
jeb
0c80217289 Fix various spelling and grammar issues in core and contrib. 2018-07-20 22:14:58 -06:00
Sergio Benitez
19d8569cdb Update core, codegen for 2018-07-16 nightly. 2018-07-17 14:06:32 -07:00
Sergio Benitez
9c7b868371 Update codegen for 2018-07-15 nightly. 2018-07-16 14:30:20 -07:00
Sergio Benitez
18a91c938e Reexport 'cookie::SameSite' from the http module. 2018-07-10 17:09:24 -07:00
Sergio Benitez
5e2502f028 Add leading underscore to avoid unused warning. 2018-07-07 19:10:50 -07:00
Sergio Benitez
69683dddd7 Mask emoji in the 'catchers' info log. 2018-07-07 19:01:00 -07:00
Sergio Benitez
351b8f7c37 Small fixes to request-local state cache implementation. 2018-07-07 18:52:03 -07:00
Ville Hakulinen
97c6b3ace8 Implement Request-Local State Cache.
Resolves #654.
2018-07-07 18:41:21 -07:00
Sergio Benitez
036e4b621c Note that the 'log' config accepts "off" in rustdocs. 2018-07-07 18:30:10 -07:00
Beatriz Rizental
965c90afc9 Add 'log = off' config option to disable all logging. 2018-07-07 18:12:25 -07:00
Sergio Benitez
7b4b0646c5 Don't color logs on Windows if enabling ASCII escapes fails. 2018-07-05 17:54:19 -07:00
Sergio Benitez
bd6cdecf00 Improve 'Config::set_raw_tls()' implementation. 2018-07-02 20:02:23 -07:00
Sergio Benitez
ce8817dd3c Clarify behavior of 'Rocket::attach()'. 2018-07-02 18:18:41 -07:00
Imron Alston
a383d49ab0 Add FLAC (audio/flac) as a known media type. 2018-06-28 19:42:59 -07:00
jeb
648eb1a5eb Prefix 'uri!' format args to allow ignored parameters. 2018-06-25 11:24:59 -07:00
Sergio Benitez
3413129296 Small fixes to code comments. 2018-06-25 11:21:02 -07:00
jeb
5b8f8eebc6 Update codegen for 2018-06-22 nightly (2/2). 2018-06-22 23:49:22 -07:00
Sergio Benitez
69c953edc9 Update codegen for 2018-06-22 nightly (1/2). 2018-06-22 23:46:42 -07:00
Sergio Benitez
64bbed1422 Improve documentation on unsafe usage.
All uses of `unsafe` are now thoroughly documented with arguments and
informal proofs of correctness as well as conditions that must hold for
these arguments to pass.

This commit also reduces the number of `unsafe` uses by 7, bringing the
count to ~10 non-test uses of `unsafe`.
2018-06-20 14:02:12 +02:00
Sergio Benitez
df7111143e Split the 'http' module into its own 'rocket_http' crate. 2018-06-07 15:34:47 +02:00
Sergio Benitez
900e716ea6 Update to Pear 0.1. 2018-06-04 18:06:08 +02:00
Sergio Benitez
1e8e4cc553 Fix Cargo.toml path to README. 2018-06-03 19:39:32 +02:00
Sergio Benitez
f171dc9d09 Reorganize repository.
The directory structure has changed to better isolate crates serving
core and contrib. The new directory structure is:

  contrib/
    lib/ - the contrib library
  core/
    lib/ - the core Rocket library
    codegen/ - the "compile extension" codegen library
    codegen_next/ - the new proc-macro library
  examples/ - unchanged
  scripts/ - unchanged
  site/ - unchanged

This commit also removes the following files:

  appveyor.yml - AppVeyor (Rust on Windows) is far too spotty for use
  rustfmt.toml - rustfmt is, unfortunately, not mature enough for use

Finally, all example Cargo crates were marked with 'publish = false'.
2018-06-03 18:44:38 +02:00