Skip to content

Commit

Permalink
Support -1 for http-max-response-time-ms for unlimited.
Browse files Browse the repository at this point in the history
  • Loading branch information
heifner committed Sep 2, 2022
1 parent da60fe3 commit 30736e9
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions plugins/http_plugin/http_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,8 @@ class http_plugin_impl : public std::enable_shared_from_this<http_plugin_impl> {
"Maximum size in megabytes http_plugin should use for processing http requests. -1 for unlimited. 429 error response when exceeded." )
("http-max-in-flight-requests", bpo::value<int32_t>()->default_value(-1),
"Maximum number of requests http_plugin should use for processing http requests. 429 error response when exceeded." )
("http-max-response-time-ms", bpo::value<uint32_t>()->default_value(30),
"Maximum time for processing a request.")
("http-max-response-time-ms", bpo::value<int64_t>()->default_value(30),
"Maximum time for processing a request, -1 for unlimited")
("verbose-http-errors", bpo::bool_switch()->default_value(false),
"Append the error log to HTTP responses")
("http-validate-host", boost::program_options::value<bool>()->default_value(true),
Expand Down Expand Up @@ -286,7 +286,12 @@ class http_plugin_impl : public std::enable_shared_from_this<http_plugin_impl> {
my->plugin_state->max_bytes_in_flight = max_bytes_mb * 1024 * 1024;
}
my->plugin_state->max_requests_in_flight = options.at( "http-max-in-flight-requests" ).as<int32_t>();
my->plugin_state->max_response_time = fc::microseconds( options.at("http-max-response-time-ms").as<uint32_t>() * 1000 );
int64_t max_reponse_time_ms = options.at("http-max-response-time-ms").as<int64_t>();
EOS_ASSERT( max_reponse_time_ms == -1 || max_reponse_time_ms >= 0, chain::plugin_config_exception,
"http-max-response-time-ms must be -1, or non-negative: ${m}", ("m", max_reponse_time_ms) );
// set to one year for -1, unlimited, since this is added to fc::time_point::now() for a deadline
my->plugin_state->max_response_time = max_reponse_time_ms == -1 ?
fc::days(365) : fc::microseconds( max_reponse_time_ms * 1000 );

my->plugin_state->validate_host = options.at("http-validate-host").as<bool>();
if( options.count( "http-alias" )) {
Expand Down

0 comments on commit 30736e9

Please sign in to comment.