Rework the data streaming

This commit is contained in:
Chunting Gu
2019-08-12 17:32:29 +08:00
parent 4f9263048f
commit 66cab76ce6
7 changed files with 123 additions and 168 deletions
+15 -8
View File
@@ -38,16 +38,23 @@ void SplitStartLine(const std::string& line, std::vector<std::string>* parts) {
// -----------------------------------------------------------------------------
ResponseParser::ResponseParser() : response_(nullptr) {
}
bool ResponseParser::Init(Response* response, bool stream) {
if (!Parser::Init(response, stream)) {
return false;
}
void ResponseParser::Init(Response* response, bool stream) {
Parser::Init(response);
response_ = response;
return true;
stream_ = stream;
}
void ResponseParser::CreateBodyHandler() {
if (stream_) {
try {
body_handler_.reset(new FileBodyHandler{ message_ });
} catch (const Error&) {
body_handler_.reset();
}
} else {
body_handler_.reset(new StringBodyHandler{ message_ });
}
}
bool ResponseParser::ParseStartLine(const std::string& line) {