Support response data streaming and add an example file downloader.

This commit is contained in:
Chunting Gu
2019-08-08 17:12:22 +08:00
parent 3077f21549
commit 0292b4b51e
19 changed files with 370 additions and 148 deletions
+10 -5
View File
@@ -31,14 +31,19 @@ void Message::SetBody(BodyPtr body, bool set_length) {
const std::string& Message::data() const {
static const std::string kEmptyData;
auto string_body = std::dynamic_pointer_cast<StringBody>(body_);
if (string_body) {
return string_body->data();
if (!string_body) {
return kEmptyData;
}
return string_body->data();
}
return kEmptyData;
std::shared_ptr<FileBody> Message::file_body() const {
auto file_body = std::dynamic_pointer_cast<FileBody>(body_);
if (!file_body) {
throw Error{ Error::kDataError, "Not a file body" };
}
return file_body;
}
bool Message::IsConnectionKeepAlive() const {