HttpParser: Add Reset() function (#1210)

This allows reuse of the HttpParser object for multiple requests.
This commit is contained in:
Peter Johnson
2018-07-22 19:41:23 -07:00
committed by GitHub
parent 794403dcea
commit c25d48fd0c
3 changed files with 39 additions and 0 deletions

View File

@@ -162,3 +162,15 @@ HttpParser::HttpParser(Type type) {
return self.m_aborted;
};
}
void HttpParser::Reset(Type type) {
http_parser_init(&m_parser,
static_cast<http_parser_type>(static_cast<int>(type)));
m_parser.data = this;
m_maxLength = 1024;
m_state = kStart;
m_urlBuf.clear();
m_fieldBuf.clear();
m_valueBuf.clear();
m_aborted = false;
}