optimize http implementation

This commit is contained in:
XieHan
2021-09-22 22:01:43 +08:00
parent 8848fb5e12
commit 49e8d500a3
4 changed files with 167 additions and 131 deletions

View File

@@ -55,8 +55,6 @@ public:
return http_parser_set_version(version, this->parser) == 0;
}
/* is_chunked(), is_keep_alive() only reflect the parsed result.
* set_header(), add_header() do not effect on it. */
bool is_chunked() const
{
return http_parser_chunked(this->parser);
@@ -95,6 +93,21 @@ public:
this->parser) == 0;
}
bool has_connection_header() const
{
return http_parser_has_connection(this->parser);
}
bool has_content_length_header() const
{
return http_parser_has_content_length(this->parser);
}
bool has_keep_alive_header() const
{
return http_parser_has_keep_alive(this->parser);
}
bool get_parsed_body(const void **body, size_t *size) const
{
return http_parser_get_body(body, size, this->parser) == 0;