Struct tiny_http::Response [] [src]

pub struct Response<R> where R: Read { /* fields omitted */ }

Object representing an HTTP response whose purpose is to be given to a Request.

Some headers cannot be changed. Trying to define the value of one of these will have no effect:

Some headers have special behaviors:


impl<R> Response<R> where R: Read

Creates a new Response object.

The additional_headers argument is a receiver that may provide headers even after the response has been sent.

All the other arguments are straight-forward.

Adds a header to the list. Does all the checks.

Returns the same request, but with an additional header.

Some headers cannot be modified and some other have a special behavior. See the documentation above.

Returns the same request, but with a different status code.

Returns the same request, but with different data.

Prints the HTTP response to a writer.

This function is the one used to send the response to the client's socket. Therefore you shouldn't expect anything pretty-printed or even readable.

The HTTP version and headers passed as arguments are used to decide which features (most notably, encoding) to use.

Note: does not flush the writer.

impl<R> Response<R> where R: Read + Send + 'static

Turns this response into a Response<Box<Read + Send>>.

impl Response<File>

Builds a new Response from a File.

The Content-Type will not be automatically detected, you must set it yourself.

impl Response<Cursor<Vec<u8>>>

impl Response<Empty>

Builds an empty Response with the given status code.

DEPRECATED. Use empty instead.

Trait Implementations

impl Clone for Response<Empty>

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more