Support data streaming on server side.

This commit is contained in:
Chunting Gu
2019-08-13 17:35:01 +08:00
parent 0ea4ab7526
commit 9b13dceab9
13 changed files with 167 additions and 59 deletions
+15 -4
View File
@@ -13,14 +13,25 @@ namespace webcc {
RequestParser::RequestParser() : request_(nullptr) {
}
void RequestParser::Init(Request* request) {
void RequestParser::Init(Request* request, ViewMatcher view_matcher) {
assert(view_matcher);
Parser::Init(request);
request_ = request;
view_matcher_ = view_matcher;
}
// TODO
void RequestParser::CreateBodyHandler() {
body_handler_.reset(new StringBodyHandler{ message_ });
bool RequestParser::OnHeadersEnd() {
bool matched = view_matcher_(request_->method(), request_->url().path(),
&stream_);
if (!matched) {
LOG_WARN("No view matches the request: %s %s", request_->method().c_str(),
request_->url().path().c_str());
}
return matched;
}
bool RequestParser::ParseStartLine(const std::string& line) {