Struct actix_web::dev::HttpResponseBuilder [] [src]

pub struct HttpResponseBuilder { /* fields omitted */ }

An HTTP response builder

This type can be used to construct an instance of HttpResponse through a builder-like pattern.

Methods

impl HttpResponseBuilder
[src]

Important traits for &'a mut W
[src]

Set HTTP status code of this response.

Important traits for &'a mut W
[src]

Set HTTP version of this response.

By default response's http version depends on request's version.

Important traits for &'a mut W
[src]

Set a header.

use actix_web::{http, HttpRequest, HttpResponse};

fn index(req: HttpRequest) -> HttpResponse {
    HttpResponse::Ok()
        .header("X-TEST", "value")
        .header(http::header::CONTENT_TYPE, "application/json")
        .finish()
}
fn main() {}

Important traits for &'a mut W
[src]

Set the custom reason for the response.

Important traits for &'a mut W
[src]

Set content encoding.

By default ContentEncoding::Auto is used, which automatically negotiates content encoding based on request's Accept-Encoding headers. To enforce specific encoding, use specific ContentEncoding` value.

Important traits for &'a mut W
[src]

Force close connection, even if it is marked as keep-alive

Important traits for &'a mut W
[src]

Enables automatic chunked transfer encoding

Important traits for &'a mut W
[src]

Force disable chunked encoding

Important traits for &'a mut W
[src]

Set response content type

Important traits for &'a mut W
[src]

Set content length

Important traits for &'a mut W
[src]

Set a cookie

use actix_web::{http, HttpRequest, HttpResponse, Result};

fn index(req: HttpRequest) -> HttpResponse {
    HttpResponse::Ok()
        .cookie(
            http::Cookie::build("name", "value")
                .domain("www.rust-lang.org")
                .path("/")
                .secure(true)
                .http_only(true)
                .finish())
        .finish()
}
fn main() {}

Remove cookie, cookie has to be cookie from HttpRequest::cookies() method.

Important traits for &'a mut W
[src]

This method calls provided closure with builder reference if value is true.

Important traits for &'a mut W
[src]

This method calls provided closure with builder reference if value is Some.

Important traits for &'a mut W
[src]

Set write buffer capacity

This parameter makes sense only for streaming response or actor. If write buffer reaches specified capacity, stream or actor get paused.

Default write buffer capacity is 64kb

[src]

Set a body and generate HttpResponse.

HttpResponseBuilder can not be used after this call.

[src]

Set a streaming body and generate HttpResponse.

HttpResponseBuilder can not be used after this call.

[src]

Set a json body and generate HttpResponse

HttpResponseBuilder can not be used after this call.

[src]

Set an empty body and generate HttpResponse

HttpResponseBuilder can not be used after this call.

[src]

This method construct new HttpResponseBuilder

Trait Implementations

impl From<HttpResponseBuilder> for HttpResponse
[src]

[src]

Performs the conversion.

impl Responder for HttpResponseBuilder
[src]

The associated item which can be returned.

The associated error which can be returned.

[src]

Convert itself to AsyncResult or Error.

impl<'a> From<&'a ClientResponse> for HttpResponseBuilder
[src]

Create HttpResponseBuilder from ClientResponse

It is useful for proxy response. This implementation copies all responses's headers and status.

[src]

Performs the conversion.

impl<'a, S> From<&'a HttpRequest<S>> for HttpResponseBuilder
[src]

[src]

Performs the conversion.

Auto Trait Implementations