将消息正文设置为文本字符串并设置“内容类型”标头。 假定该字符串的字符编码是操作系统的默认代码页,并对 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")
);
参数
body_text
json 值。content_type
具有消息主体 MIME 类型的字符串。body_data
包含正文数据的向量。stream
可读开放式异步流。content_length
要在主体中发送的数据的大小。
备注
这会覆盖所有之前设置的正文数据和“内容类型”标头。
要求
**标头:**http_msg.h
**命名空间:**web::http