-
Notifications
You must be signed in to change notification settings - Fork 65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
rpcdaemon: add HTTP gzip compression (no streaming) #1909
Conversation
831e849
to
06c3797
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can address suggestions in next PR
@@ -190,10 +192,11 @@ Task<void> Connection::handle_actual_request(const boost::beast::http::request<b | |||
vary_ = req[boost::beast::http::field::vary]; | |||
origin_ = req[boost::beast::http::field::origin]; | |||
method_ = req.method(); | |||
auto encoding = req[boost::beast::http::field::accept_encoding]; | |||
|
|||
auto rsp_content = co_await request_handler_.handle(req.body()); | |||
if (rsp_content) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The definition of local variable encoding
should be moved inside this code branch for better readability
@@ -190,10 +192,11 @@ Task<void> Connection::handle_actual_request(const boost::beast::http::request<b | |||
vary_ = req[boost::beast::http::field::vary]; | |||
origin_ = req[boost::beast::http::field::origin]; | |||
method_ = req.method(); | |||
auto encoding = req[boost::beast::http::field::accept_encoding]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
encoding
should be declared const
(next PR is OK for this and all following suggestions)
|
||
auto rsp_content = co_await request_handler_.handle(req.body()); | ||
if (rsp_content) { | ||
co_await do_write(rsp_content->append("\n"), boost::beast::http::status::ok); | ||
co_await do_write(rsp_content->append("\n"), boost::beast::http::status::ok, !encoding.empty()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The value of the Accept-Encoding
field should be passed to the do_write
method instead of a bool
. This will allow for checking within do_write
which kind of content compression has been requested and accept/reject it depending on the supported compression on our side
compress_data(content, compressed_data); | ||
} catch (const std::exception& e) { | ||
SILK_ERROR << "Connection::compress_data exception: " << e.what(); | ||
throw; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure we do really want to raise an exception here, probably we could directly return an Internal server error
code or something similar
@@ -114,6 +116,8 @@ class Connection : public StreamWriter { | |||
std::string vary_; | |||
std::string origin_; | |||
boost::beast::http::verb method_{boost::beast::http::verb::unknown}; | |||
|
|||
char temp_compressed_buffer_[10 * 1024 * 1024]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should use std::string
or std::vector<char>
here
No description provided.