Commit Graph

33 Commits

Author SHA1 Message Date
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 3bebdcc53d Add Response::body_string(). Use it in all tests. 2017-04-14 01:59:28 -07:00
Sergio Benitez 0c44e44641 Use the `RawStr` type for all form raw strings.
This is a breaking change.

This commit introduces `RawStr` to forms. In particular, after this
commit, the `&str` type no longer implements `FromFormValue`, and so it
cannot be used as a field in forms. Instad, the `&RawStr` can be used.

The `FormItems` iterator now returns an `(&RawStr, &RawStr)` pair.
2017-03-30 23:06:53 -07:00
Sergio Benitez 65da988962 Return a `LaunchError` from `launch` when launching fails.
This is a (minor) breaking change. If `rocket.launch()` is the last expression
in a function, the return type will change from `()` to `LaunchError`. A simple
workaround that preserves the previous functionality is to simply add a
semicolon after `launch()`: `rocket.launch();`.

resolves #34
2017-03-15 22:10:09 -07:00
Sergio Benitez a4f532da09 Set examplem versions to 0.0.0. 2017-03-08 14:29:24 -08:00
Sergio Benitez 0acfea9c71 Remove unnecessary pub qualifier in forms example. 2017-02-16 18:30:44 -08:00
Sergio Benitez a9c3b8a919 Silence warnings during testing. 2017-02-02 02:16:21 -08:00
Sergio Benitez 4d2f695db0 Add more bad form tests to forms example. 2017-02-01 18:35:54 -08:00
Garrett Squire 11e90f525f Update status code for form processing failure. 2017-02-01 18:29:29 -08:00
Sergio Benitez 44e367c64c Remove authorship from all examples. 2017-01-19 17:14:01 -08:00
Liigo Zhuang 0af01abe5f Fix decoding of String form values.
@liigo originated a fix and found the problem in #82.
2016-12-31 01:06:22 -06:00
Sergio Benitez 83bbea7d4a Fix decoding of form value Strings. 2016-12-31 00:48:31 -06:00
Sergio Benitez f1c7d3e27c Minor code improvements via clippy. 2016-12-17 09:18:30 -08:00
Sergio Benitez 368e5105a9 Return a Response from testing's dispatch_with. 2016-12-15 20:53:54 -08:00
Sergio Benitez 08f41816d1 Remove dependence from Hyper in Request/MockRequest. 2016-12-15 16:34:19 -08:00
Sergio Benitez 44f5f1998d New HTTP types: ContentType, Status. Responder/Handler/ErrorHandler changed.
This is a complete rework of `Responder`s and of the http backend in
general. This gets Rocket one step closer to HTTP library independence,
enabling many future features such as transparent async I/O, automatic
HEAD request parsing, pre/post hooks, and more.

Summary of changes:

  * `Responder::response` no longer takes in `FreshHyperResponse`.
    Instead, it returns a new `Response` type.
  * The new `Response` type now encapsulates a full HTTP response. As a
    result, `Responder`s now return it.
  * The `Handler` type now returns an `Outcome` directly.
  * The `ErrorHandler` returns a `Result`. It can no longer forward,
    which made no sense previously.
  * `Stream` accepts a chunked size parameter.
  * `StatusCode` removed in favor of new `Status` type.
  * `ContentType` significantly modified.
  * New, lightweight `Header` type that plays nicely with `Response`.
2016-12-15 00:47:31 -08:00
Sergio Benitez 5b8b41bcd8 Fix examples for updates Redirect API. 2016-11-03 19:09:08 +01:00
Sergio Benitez a145a11848 Add tests to the hello_world, helllo_ranks, and hello_person examples. 2016-10-17 15:14:57 -07:00
Sergio Benitez 2f35b23514 Remove non-streaming requests. Use streaming requests everywhere.
This commit includes the following important API changes:

  * The `form` route parameter has been removed.
  * The `data` route parameter has been added.
  * Forms are not handled via the `data` parameter and `Form` type.
  * Removed the `data` parameter from `Request`.
  * Added `FromData` conversion trate and default implementation.
  * Added `DataOutcome` enum, which is the return type of `from_data`.
  * 'FromData' is now used to automatically derive the `data` parameter.
  * Moved `form` into `request` module.
  * Removed `Failure::new` in favor of direct value construction.

This commit includes the following important package additions:

  * Added a 'raw_upload' example.
  * `manual_routes` example uses `Data` parameter.
  * Now building and running tests with `--all-features` flag.
  * All exmaples have been updated to latest API.
  * Now using upstream Tera.

This commit includes the following important fixes:

  * Any valid ident is now allowed in single-parameter route parameters.
  * Lifetimes are now properly stripped in code generation.
  * `FromForm` derive now works on empty structs.
2016-10-12 00:14:42 -07:00
Sergio Benitez 4b6c72e33f Use move builder pattern to launch Rocket apps. 2016-10-03 19:48:33 -07:00
Sergio Benitez 7b1dc5a1a4 Remove Rocket::new(). Use 'ignite' everywhere. 2016-10-03 19:37:49 -07:00
Sergio Benitez 4e03bb6107 Add NamedFile response type. 2016-09-12 01:51:02 -07:00
Sergio Benitez 46f73ed57c Renamed macros to codegen. 2016-09-08 20:38:58 -07:00
Sergio Benitez 4d301eebbd Complete overhaul complete. 2016-09-04 04:06:28 -07:00
Sergio Benitez 025c9243c0 Now using a Cargo workspace for (much!) faster builds. Added a temporary query
params example.
2016-08-10 17:50:08 -07:00
Sergio Benitez eabb5169de Added method specific macros. 2016-08-08 18:34:18 -07:00
Sergio Benitez 0041724aa4 Slightly cleaner form exmaple. 2016-04-04 19:02:51 -07:00
Sergio Benitez d0dd49f98d Implemented FromForm derivation. Woo! 2016-04-04 04:14:18 -07:00
Sergio Benitez b7d22d58f7 Actually useful forms! 2016-04-03 22:41:31 -07:00
Sergio Benitez 3e449d2fb9 Forms are now working! 2016-04-03 21:53:25 -07:00
Sergio Benitez 50bc0d6999 Major refactoring.
Here's the idea: under the `Rocket` namespace should live things critical to
writing simple Rocket apps: Request, Response, Error, etc. Nothing should be
nested more than one level deep. Only items required for more complex things
(implementing uncommon traits, etc.) should be nested one level deep.

This commit is the first attempt at realizing this.
2016-04-01 16:54:53 -07:00
Sergio Benitez d477c18062 Major progress towards form support. 2016-03-30 01:02:21 -07:00
Sergio Benitez fb8fdc3bc2 Cleaned up response -> split into files. Started form example.
There's something going on with Hyper. When a 303 (see other) response is sent
in response to a POST, the browser does a GET to the location header. Hyper
somehow misreads the method parameter here, resulting in a route failer.

I need to MITM the connection to see exactly what the browser is sending and
what Hyper is receiving to see who's wrong.
2016-03-28 02:34:09 -07:00