Commit Graph

371 Commits

Author SHA1 Message Date
Sergio Benitez a6c4d053ad Switch to 'yansi' for all terminal coloring.
Resolves #299.
2017-06-01 22:10:05 -07:00
Sergio Benitez 73fed03ef4 New version: 0.2.8. 2017-06-01 22:10:05 -07:00
Sergio Benitez e42fe78e41 Update 'smallvec' dependency to 0.4. 2017-05-31 17:28:12 -07:00
Sergio Benitez 923b84f42c Remove outdated comment FIXME. 2017-05-29 18:10:07 -07:00
Sergio Benitez 6a9421935e Add 'Request::route' method to get active 'Route'.
This commit also adds the `base` field to `Route` which allows the
base mount point to be retrieved. Finally, this commits adds an
implementation of `FromRequest` for `Route` which returns the active
route if one is available or forwards otherwise.

This commit is a breaking change: it makes `Request` and `MockRequest`
invariant over the lifetime `'r`. While this shouldn't affect most
applications, it may affect some.

Resolves #108.
2017-05-29 18:00:33 -07:00
Sergio Benitez 5f2b2ee3df New version: 0.2.7. 2017-05-26 20:37:54 -07:00
Sergio Benitez 6a5d8ab58a Update rustls and hyper-rustls dependencies. 2017-05-24 16:02:16 -07:00
Sergio Benitez 299a422cbc Optimize MediaType::Display, ContentType::Into<Header>, and precheck.
Differential and causal profiling determined that 35% of `Hello, world!`
dispatch time was spent rendering `Content-Type` due to many calls to `fmt` in
`MediaType::Display` and an allocation in `ContentType::Into<Header>`. This
change reduces the number of calls to `fmt` to 1 in `MediaType::Display` and
removes the allocation in `Into<Header>` for known media types.

This change also caches a `Rocket` "precheck" so that pre-dispatch checks are
done only a single time for a given `Rocket` instance, further reducing
`MockRequest::dispatch_with` time for "Hello, world!" by roughly 15%.
2017-05-23 16:41:38 -07:00
Sergio Benitez d93d366ce7 Remove use of type_ascription feature. 2017-05-20 11:51:17 -07:00
Sergio Benitez 6c00d362c0 Add ResponseBuilder::raw_body. Use OrderMap for HeaderMap. 2017-05-20 11:41:44 -07:00
Sergio Benitez 80a1abdc89 Add hello_world benchmark. 2017-05-19 19:39:10 -07:00
Sergio Benitez 42c98fe1c3 Rename 'extra' Request field to 'state'. 2017-05-19 19:38:56 -07:00
Sergio Benitez fc7d51d010 Check before dumping data in kill_stream. 2017-05-19 19:38:28 -07:00
Sergio Benitez 4cab891fda Default session removal cookie path to '/'.
Fixes #295.
2017-05-19 03:46:19 -07:00
Sergio Benitez 9b955747e4 Remove config global state. Use Responder::respond_to.
This commit includes two major changes to core:

  1. Configuration state is no longer global. The `config::active()`
     function has been removed. The active configuration can be
     retrieved via the `config` method on a `Rocket` instance.

  2. The `Responder` trait has changed. `Responder::respond(self)` has
     been removed in favor of `Responder::respond_to(self, &Request)`.
     This allows responders to dynamically adjust their response based
     on the incoming request.

Additionally, it includes the following changes to core and codegen:

  * The `Request::guard` method was added to allow for simple
    retrivial of request guards.
  * The `Request::limits` method was added to retrieve configured
    limits.
  * The `File` `Responder` implementation now uses a fixed size body
    instead of a chunked body.
  * The `Outcome::of<R: Responder>(R)` method was removed while
    `Outcome::from<R: Responder(&Request, R)` was added.
  * The unmounted and unmanaged limits are more cautious: they will only
    emit warnings when the `Rocket` receiver is known.

This commit includes one major change to contrib:

  1. To use contrib's templating, the fairing returned by
     `Template::fairing()` must be attached to the running Rocket
     instance.

Additionally, the `Display` implementation of `Template` was removed. To
directly render a template to a `String`, the new `Template::show`
method can be used.
2017-05-19 03:29:08 -07:00
Sergio Benitez 28a1ef0916 Fairings, v3.
Modifying the `Rocket` structure just before launch doesn't make sense for
several reasons: 1) those affects can't influence the launch, and 2) they won't
be observed in tests. Thus, an `Attach` fairing kind was added that ameliorates
these issues.
2017-05-17 01:39:36 -07:00
Sergio Benitez 9c9740f966 Fairings v2. 2017-05-14 21:46:01 -07:00
Sergio Benitez 9a7484f7a8 Reclose connection on unread data. Minimum nightly is 1.19. 2017-05-13 02:00:35 -07:00
Anton Pirker 781477fff1 Rename 'session_key' config parameter to 'secret_key'.
Resolves #220.
2017-05-12 17:24:25 -07:00
Sergio Benitez 5e345e99d0 Make I/O and parsing TLS file errors distinct. 2017-05-12 14:38:18 -07:00
Sergio Benitez a9d9ef3867 Update rustls, cookie, and hyper-rustls dependencies. 2017-05-12 14:36:32 -07:00
Sergio Benitez 6907fd432c Update base64 to secure version. 2017-05-08 15:28:46 -07:00
Sergio Benitez 84255af4f9 Update base64 dependency to 0.5. 2017-05-05 12:40:57 -07:00
Sergio Benitez 30fac32978 Upgrade dependencies to Serde 1.0.
Closes #272.
Resolves #273.
2017-04-24 17:37:18 -07:00
Sergio Benitez 40d11929d7 Optimize the creation of the Data structure. 2017-04-24 01:33:00 -07:00
Sergio Benitez 45eb475607 Use unboxed WrappedStream. 2017-04-22 22:17:21 -07:00
Sergio Benitez 0a8de2f0a6 Ensure that all raw HTTP data is transfer-decoded. 2017-04-22 22:06:33 -07:00
Sergio Benitez 1e5a1b8940 Remove 'testing' feature. Close stream on network error.
This is a breaking change.

The `testing` feature no longer exists. Testing structures can now be
accessed without any features enabled.

Prior to this change, Rocket would panic when draining from a network
stream failed. With this change, Rocket force closes the stream on any
error.

This change also ensures that the `Fairings` launch output only prints
if at least one fairing has been attached.
2017-04-20 20:36:12 -07:00
Sergio Benitez ac0c78a0cd Initial implementation of fairings: structured middleware for Rocket.
Closes #55.
2017-04-20 13:44:19 -07:00
Sergio Benitez f2d054c4a2 Use upstream hyper. 2017-04-19 23:42:12 -07:00
Sergio Benitez 41386cfb78 Display the port that was resolved, not configured. 2017-04-19 02:51:44 -07:00
Sergio Benitez 7b48ca7103 Add optional input for IntoOutcome. Add mapper methods to Outcome.
This is a breaking change to `IntoOutcome`.

The MsgPack and JSON types now use `into_outcome` to generate the final
`Outcome` from their `FromData` implementations.

Resolves #98.
2017-04-18 21:56:21 -07:00
Joshua Rombauer 0e759edf78 Implement 'From<T>' for 'Stream<T>' instead of custom 'from'.
Closes #267.
2017-04-18 18:18:37 -07:00
Sergio Benitez d6e86be1b0 Make route collisions a hard error.
This is a breaking change. Previously, route collisions were warnings.
2017-04-18 17:42:44 -07:00
Sergio Benitez 1524b9a6b2 Document size limits. 2017-04-18 00:36:39 -07:00
Sergio Benitez 6dc21e5380 Add support for configurable size limits. 2017-04-18 00:25:13 -07:00
Sergio Benitez e6bbeacb1c New version: 0.2.6. 2017-04-17 16:21:56 -07:00
Sergio Benitez a1c4cc2224 Improve display of table config value. 2017-04-17 00:34:47 -07:00
Sergio Benitez 9b7f58448a New version: 0.2.5. 2017-04-16 14:29:04 -07:00
Sergio Benitez 73e39dcf17 Fix small typo: It -> In. 2017-04-16 00:59:52 -07:00
Sergio Benitez 586d46ae9c Use upstream smallvec. 2017-04-15 19:03:40 -07:00
Sergio Benitez 6641e9b92d Add Response::content_type() method. 2017-04-14 14:35:22 -07:00
Sergio Benitez 3bebdcc53d Add Response::body_string(). Use it in all tests. 2017-04-14 01:59:28 -07:00
Sergio Benitez 0d674c57fd Return `HeaderMap` from Response::headers(). Remove Response::header_values().
This is a breaking change. A call to `Response::headers()` can be
replaced with `Response::headers().iter()`. A call to
`Response::header_values()` can be replaced with
`Response::headers().get()`.
2017-04-14 01:21:06 -07:00
Sergio Benitez 2e54a1f74d Don't use &str where RawStr is now preferred. 2017-04-14 00:43:57 -07:00
Sergio Benitez a25a3c69c6 Cache parsed ContentType and Accept headers.
This is a breaking change. `Request::content_type` now returns a borrow
to `ContentType`. `FromRequest` for `ContentType` is no longer
implemented. Instead, `FromRequest` for `&ContentType` is implemented.
2017-04-13 02:44:47 -07:00
Sergio Benitez e50164115b Only emit TLS disabled error on misconfig. 2017-04-13 01:30:48 -07:00
Sergio Benitez 6f29696b4f Make TLS misconfig an error. Always print launch message. 2017-04-13 01:16:09 -07:00
Sergio Benitez 1516ca4fb6 Initial TLS support.
This commit introduces TLS support, provided by `rustls` and a fork of
`hyper-rustls`. TLS support is enabled via the `tls` feature and
activated when the `tls` configuration parameter is set. A new
`hello_tls` example illustrates its usage.

This commit also introduces more robust and complete configuration
settings via environment variables. In particular, quoted string,
array, and table (dictionaries) based configuration parameters can now
be set via environment variables.

Resolves #28.
2017-04-13 00:18:31 -07:00
Sergio Benitez a2a0aab541 Depend on cookie >= 0.7.4 for ring bugfix. 2017-04-11 16:56:10 -07:00