Share via


http_response::set_body Method

Sets the body of the message to a textual string and set the "Content-Type" header. Assumes the character encoding of the string is the OS's default code page and will perform appropriate conversions to UTF-8.

void set_body(
   const utility::string_t &body_text,
   utility::string_t content_type = utility::string_t(U("text/plain"))
);

void set_body(
   std::string body_text,
   utility::string_t content_type = utility::string_t(U("text/plain; charset=utf-8"))
);

void set_body(
   const json::value &body_data
);

void set_body(
   std::vector<unsigned char> body_data
);

void set_body(
   concurrency::streams::istream stream,
   utility::string_t content_type = U("application/octet-stream")
);

void set_body(
   concurrency::streams::istream stream,
   size_t content_length,
   utility::string_t content_type = U("application/octet-stream")
);

Parameters

  • body_text
    json value.

  • content_type
    A string holding the MIME type of the message body.

  • body_data
    Vector containing body data.

  • stream
    A readable, open asynchronous stream.

  • content_length
    The size of the data to be sent in the body.

Remarks

This will overwrite any previously set body data and "Content-Type" header.

Requirements

Header: http_msg.h

Namespace: web::http

See Also

Reference

http_response Class