Commit Graph

234 Commits

Author SHA1 Message Date
Jacob Pratt 1f90a9b6d1 Update hyper to '=0.13.0-alpha.1'. 2020-07-11 09:24:28 -07:00
Jeb Rosen 047b1620f9 Update pinned hyper and tokio versions. 2020-07-11 09:24:28 -07:00
Jacob Pratt e44c5896b8 Remove stabilized 'async_await' feature gate and update the minimum nightly version. 2020-07-11 09:24:28 -07:00
Jeb Rosen af95129590 Use futures 0.3-compatible hyper and tokio and the tokio runtime instead
of futures-rs executor.

Despite this change, using body_bytes_wait on (for example) a File will
still fail due to tokio-rs/tokio#1356.
2020-07-11 09:24:28 -07:00
Jeb Rosen 633e495a6b Update many doc tests in 'core' for async. 2020-07-11 09:24:28 -07:00
Jeb Rosen 5d439bafc0 Convert core to async and add support for async routes.
Minimum rustc bump required for rust-lang/rust#61775
2020-07-11 09:24:28 -07:00
Marc Schreiber 96b4142156 Upgrade to hyper 0.12.
* Use hyper's 'MakeService' implementation with futures API.
  * Use tokio runtime to serve HTTP backend.
2020-07-11 09:24:03 -07:00
gcarq 86d0bdddb2 Replace manual ASCII checks with 'std::char' calls. 2020-06-22 05:07:14 -07:00
Sergio Benitez 55d2b2bfb6 Properly mock 'Key::try_generate()'. 2020-06-07 04:02:35 -07:00
Sergio Benitez ea9865ec42 Allow multiple versions of 'rustls' and 'ring'.
Co-authored-by: TotalKrill <kristoffer.odmark90@gmail.com>
2020-06-04 18:59:11 -07:00
Sergio Benitez 3c47fa895a Enable minimal set of 'cookie' features. 2020-06-04 18:54:23 -07:00
Sergio Benitez 3f20e4ac93 Use proper SPDX license expression in 'Cargo.toml'. 2020-06-03 23:02:05 -07:00
Jeb Rosen 097fbd7df0 Fix some broken links in API documentation. 2020-05-31 11:32:14 -07:00
Yusuke Kominami a21221aeb6 Replace deprecated 'OffsetDateTime::now' with 'OffsetDateTime::now_utc'.
Update 'time' dependency accordingly.
2020-05-30 11:13:40 -07:00
Sergio Benitez ee5988fe5c Update 'cookie' to '0.14'. 2020-05-30 01:49:32 -07:00
Sergio Benitez 578038619f Add 'Origin::map_path()' method. 2020-05-29 17:49:37 -07:00
Sergio Benitez 06e146e7d1 Update 'time' to 0.2 in 'contrib'. 2020-03-25 14:39:55 -07:00
Sergio Benitez 53353df633 Fix more broken links. 2020-03-09 02:03:38 -07:00
Sergio Benitez d0bfd8a3bb Update 'cookie' to 0.13.2. 2020-01-29 14:17:01 -08:00
Sergio Benitez f35e3c4aca Set cookies even on error responses.
Fixes #1213.
2020-01-23 21:10:04 -08:00
Sergio Benitez 7c1b8dc9ad Update 'cookie' to 0.13, 'rustls' to 0.16. 2020-01-21 16:10:04 -08:00
Paolo Barbolini cd5f96ae15 Update 'uuid', 'unicode-xid', and 'base64' dependencies. 2019-11-30 09:33:14 -08:00
Matt Brubeck 8bf6aa2068 Update 'smallvec' to '1.0'. 2019-11-16 13:02:50 -08:00
Jacob Pratt 4e6a7ddd5f Remove use of the 'crate_visibility_modifier' feature.
Most items with 'crate' visibility become 'pub(crate)'.
Items are made 'pub' instead when they would remain private.
2019-09-21 09:16:04 -07:00
Jacob Pratt bed93133b8 Abide by formatting in 'Debug' implementations. 2019-09-18 19:06:08 -07:00
Sergio Benitez b7e688cefa Remove use of deprecated 'IndexMap::remove()'.
Use 'IndexMap::swap_remove()' in its place.
2019-09-09 16:51:51 -07:00
Sergio Benitez 99a864008c Remove use of specialization in http. 2019-09-09 16:45:03 -07:00
Sergio Benitez 6ed4c098f1 Stop exporting 'mime' and relevant conversions. 2019-09-09 16:42:44 -07:00
Jacob Pratt 2dd09f90be Remove unused 'doc_cfg' feature. 2019-08-06 14:01:35 -07:00
Jeb Rosen 3e4f8453ce Remove use of the 'decl_macro' feature.
Also removes one internal use in the 'typed-uris' codegen test.
2019-07-19 11:39:56 -07:00
Jacob Pratt 34a741a26e Remove use of '!' type in favor of 'Infallible'.
This removes the use of and dependence on the 'never_type' feature.
2019-07-09 15:10:51 -07:00
Sergio Benitez 7f2c9f426c Fix tests for Windows. 2019-07-06 00:59:01 -07:00
Jeb Rosen 90e37beb2f Migrate http to Rust 2018. 2019-06-25 13:43:53 -04:00
Brenden Matthews ba6aa2f05e Bump cookie, rustls, and hyper-sync-rustls dependencies. 2019-05-14 22:25:55 -07:00
Sergio Benitez 1caf87eb21 Move to 0.5.0-dev on master. 2019-05-13 16:18:48 -07:00
Jacob Pratt 9b219ddc01 Remove stabilized feature gates.
* try_from
* transpose_result
2019-04-12 18:48:51 -07:00
Sergio Benitez f0c6c9b26f Use explicit associated type in 'IntoOwned' impl. 2019-02-06 19:37:39 -08:00
Sergio Benitez ca5623c641 Type encoding to fix encoding issues once and for all.
Fixes #849.
2018-12-12 17:38:36 -08:00
Sergio Benitez 5056705884 Improve query string routing and typed URI docs. 2018-12-07 12:09:15 -08:00
Sergio Benitez b88a2d7d05 Add notes about enabling features to contrib docs. 2018-12-07 09:07:27 -08:00
Sergio Benitez a4dcb0cf4c New version: 0.4.0. 2018-12-06 09:19:11 -08:00
Sergio Benitez d7933dd6fd Implement ignorable 'uri!' expressions.
Closes #840.
2018-12-06 08:43:24 -08:00
Sergio Benitez 90a6749313 New version: 0.4.0-rc.2. 2018-11-30 21:00:18 -08:00
Sergio Benitez b7db74144f Parameterize 'UriDisplay' with 'Path' or 'Query'.
This commit introduces the sealed `UriPart` marker trait as well as the
implementing `Path` and `Query` marker types, allowing for parts of a
URI to be distinguished at the type level. Consequently, `UriDisplay`
has been parameterized with `P: UriPart`, creating `UriDisplay<Path>`
and `UriDisplay<Query>`. The effect of this change is improved type
safely for URI rendering as well as the ability to omit rendering values
in query parts via `Option` and `Result`.

The `UriDisplay` derive was replaced by `UriDisplayQuery` and
`UriDisplayPath` which derive implementations for `UriDisplay<Path>`
and `UriDisplay<Query>`, respectively.

This commit also works around a rustdoc visibility issue by creating a
hidden `http::private` module.

Finally, this commit also removes the now vestigial use of the
`rustc_private` feature in codegen.

Fixes #827.
2018-11-27 10:01:47 -06:00
Alva Snædís 4dea9eed36 Mention that u128, i128 implement UriDisplay. 2018-11-11 21:51:42 -08:00
Sergio Benitez 4224419e63 Reduce 'cfg' usage for 'private-cookies' feature. 2018-11-08 23:56:15 -08:00
Linus Unnebäck 53758c6dd7 Introduce the 'private-cookies' feature. 2018-11-08 23:38:18 -08:00
Alex Bowers 32e2ff4d6b Add ZIP (application/zip) as a known media type. 2018-11-08 20:47:26 -08:00
Sergio Benitez a2ada84986 Move 'UriDisplay' note to top of 'FromUriParam' docs. 2018-11-05 15:02:11 -08:00
Sergio Benitez 5762208bba Percent-encode characters: '[', ']', '\', '^', '|'.
Fixes #808.
2018-11-02 00:10:01 -07:00
Sergio Benitez 4dbd87a36f New version: 0.4.0-rc.1. 2018-10-31 14:35:30 -07:00
Sergio Benitez 7b2b6aba81 Use published version of 'pear'. 2018-10-28 20:17:44 -07:00
Sergio Benitez 3f2e724b23 Update rustls to 0.14. 2018-10-27 18:14:17 -07:00
Sergio Benitez 556206e8b3 Version all URLs to 'rocket.rs'. 2018-10-26 21:20:12 -07:00
Sergio Benitez 3798cd3e65 Document and test 'UriDisplay', its derive, and 'Formatter'. 2018-10-25 02:53:04 -07:00
Divyahans Gupta 34421f13f3 Allow nested values in 'UriDisplay'. 2018-10-24 21:57:53 -07:00
Sergio Benitez 26db5ecb4e Fix normalization and Windows issues. 2018-10-24 00:01:56 -07:00
Sergio Benitez ea158d4344 Individually document proc bang macros and derives. 2018-10-15 15:27:47 -07:00
Sergio Benitez 05eee14d90 Update pear to latest revision. 2018-10-14 23:49:02 -07:00
Sergio Benitez 28f2a33abd Use inter/intra-crate links in all documentation. 2018-10-09 04:31:09 -07:00
Sergio Benitez 2839aca8ce Update features for latest nightly. 2018-10-09 04:31:09 -07:00
Sergio Benitez 360b0e80b0 Port all codegen tests to codegen_next. 2018-10-09 04:31:08 -07:00
Sergio Benitez b9bf1ee37d Fix typed URI generation for query reform. 2018-10-09 04:31:08 -07:00
Sergio Benitez 61f107f550 Reimplement route attribute as a proc-macro.
This commits also implement the query reform from #608. It also consists
of many, many breaking changes. Among them are:

  * Query parts in route paths use new query reform syntax.
  * Routing for queries is now lenient.
    - Default ranking has changed to reflect query reform.
  * Format routing matching has been fixed.
    - Routes with formats matching "accept" will always collide.
    - Routes with formats matching "content-type" require requests to
      have an equivalent content-type header to match.
    - Requests with imprecise content-types are treated as not having a
      content-type.
  * Generated routes and catchers respect visibility modifiers.
  * Raw getter methods from request were renamed and retooled.
    - In particular, the index parameter is based on segments in the
      route path, not dynamic parameters.
  * The method-based attributes no longer accept a keyed 'path'.
  * The 'rocket_codegen' crate is gone and will no longer be public.
  * The 'FormItems' iterator emits values of type 'FormItem'.
    - The internal form items' string can no longer be retrieved.
  * In general, routes are more strictly validated.
  * Logging from codegen now funnels through logging infrastructure.
  * Routing has been optimized by caching routing metadata.

Resolves #93.
Resolves #608.
Resolves #693.
Resolves #476.
2018-10-09 04:18:04 -07:00
Sergio Benitez 3eb873d89d Tidy 'uri!' proc-macro. Improve error reporting. 2018-10-04 02:00:04 -07:00
Sergio Benitez 1a3fd1d237 Add known media types and extensions.
Adds the following to the list of known media types:

  * audio/webm (WEBA)
  * image/tiff (TIFF)
  * audio/aac (AAC)
  * text/calendar (Calendar)
  * video/mpeg (MPEG)
  * application/x-tar (TAR)
  * application/gzip (GZIP)
  * video/quicktime (MOV)
  * video/mp4 (MP4)

Also adds the following to the list of known extensions:

  * .weba (WEBA)
  * .ogv (OGG)
  * .mp4 (MP4)
  * .mpeg4 (MP4)
  * .aac (AAC)
  * .ics (Calendar)
  * .bin (Binary)
  * .mpg (MPEG)
  * .mpeg (MPEG)
  * .tar (TAR)
  * .gz (GZIP)
  * .tif (TIFF)
  * .tiff (TIFF)
  * .mov (MOV)
2018-09-18 18:25:39 -07:00
Sergio Benitez 112e700836 Reimplement 'catch' attribute as a proc-macro. 2018-09-16 01:32:40 -07:00
jeb cfdb2a404b Add Icon (image/x-icon) as a known media type. 2018-09-11 15:16:06 -07:00
Tal 8172f748b3 Implement 'Clone' for all URI types. 2018-09-03 19:42:34 -07:00
jeb 1da506ea5d Remove use of the 'const_fn' feature. 2018-09-03 19:41:31 -07:00
Sergio Benitez fd6d577158 Remove 'use_extern_macros' feature: stabilized. 2018-08-18 17:06:28 -07:00
Sergio Benitez 7b4747ff1c Fix 'Segments::into_path_buf()' docstring. 2018-08-17 11:14:45 -07:00
Sergio Benitez b642e94a2c Reduce or consolidate git-based dependencies. 2018-08-15 19:44:35 -07:00
Sergio Benitez 651c202060 Move 'SegmentError' into 'uri' module. 2018-08-13 02:14:16 -07:00
Sergio Benitez fe59a7fe38 Use better types for 'Error' associated types. 2018-08-10 04:42:30 -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
Sean Stangl a7cc5542ab Fix various clippy warnings in core and codegen. 2018-07-25 15:28:35 -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 18a91c938e Reexport 'cookie::SameSite' from the http module. 2018-07-10 17:09:24 -07:00
Imron Alston a383d49ab0 Add FLAC (audio/flac) as a known media type. 2018-06-28 19:42:59 -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