Struct gotham::test::TestResponse [] [src]

pub struct TestResponse { /* fields omitted */ }

Wrapping struct for the Response returned by a TestClient. Provides access to the Response value via the Deref and DerefMut traits, and also provides a function for awaiting a completed response body.

Examples

use gotham::test::TestServer;

let test_server = TestServer::new(|| Ok(my_handler)).unwrap();

let response = test_server.client().get("http://localhost/").perform().unwrap();
assert_eq!(response.status(), StatusCode::Ok);
let body = response.read_body().unwrap();
assert_eq!(&body[..], b"This is the body content.");

Methods

impl TestResponse
[src]

[src]

Awaits the body of the underlying Response, and returns it. This will cause the event loop to execute until the Response body has been fully read into the Vec<u8>.

[src]

Awaits the UTF-8 encoded body of the underlying Response, and returns the String. This will cause the event loop to execute until the Response body has been fully read and the String created.

Methods from Deref<Target = Response>

[src]

Get the HTTP version of this response.

[src]

Get the headers from the response.

[src]

Get a mutable reference to the headers.

[src]

Get the status from the server.

[src]

Set the StatusCode for this response.

[src]

Set the status and move the Response.

Useful for the "builder-style" pattern.

[src]

Set a header and move the Response.

Useful for the "builder-style" pattern.

[src]

Set the headers and move the Response.

Useful for the "builder-style" pattern.

[src]

Set the body.

[src]

Set the body and move the Response.

Useful for the "builder-style" pattern.

[src]

Read the body.

[src]

Take the Body of this response.

Trait Implementations

impl Deref for TestResponse
[src]

The resulting type after dereferencing.

[src]

Dereferences the value.

impl DerefMut for TestResponse
[src]

[src]

Mutably dereferences the value.