diff options
author | Azat Khuzhin <azat@libevent.org> | 2020-05-25 11:25:18 +0300 |
---|---|---|
committer | Azat Khuzhin <azat@libevent.org> | 2020-05-25 11:25:18 +0300 |
commit | 7426a568d009c34fbef9ab607aedab9d05fc29ec (patch) | |
tree | c3f4c08ea3a293f2e6d497866409ab7e7ba52a7d /include | |
parent | f10aaea37433b60ed3e0b7adcc7b1764c8b0b518 (diff) | |
parent | 95c1c200c182d96f49930a15ad433a7049e61b06 (diff) | |
download | libevent-7426a568d009c34fbef9ab607aedab9d05fc29ec.tar.gz |
http: Merge branch 'http-max_connections-pr-592'
@jcoffland:
"When the max connection limit is enabled and the limit is reached, the
server will respond immediately with 503 Service Unavailable. This can
be used to prevent servers from running out of file descriptors. This is
better than request limiting because clients may make more than one
request over a single connection. Blocking a request does not
necessarily close the connection and free up a socket."
* http-max_connections-pr-592:
test: cover evhttp max connections
Added evhttp max simultaneous connection limiting
Diffstat (limited to 'include')
-rw-r--r-- | include/event2/http.h | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/include/event2/http.h b/include/event2/http.h index 7d4d2881..eba8f237 100644 --- a/include/event2/http.h +++ b/include/event2/http.h @@ -224,6 +224,24 @@ EVENT2_EXPORT_SYMBOL void evhttp_set_max_body_size(struct evhttp* http, ev_ssize_t max_body_size); /** + * Set the maximum number of simultaneous connections for this server. + * A value of zero or less disables the limit. + * + * @param http the http server on which to set the max connection limit + * @param max_connections the maximum number of simultaneous connections or 0 + */ +EVENT2_EXPORT_SYMBOL +void evhttp_set_max_connections(struct evhttp* http, int max_connections); + +/** + * Get the current number of connections. + * + * @return The current number of connections for this server. + */ +EVENT2_EXPORT_SYMBOL +int evhttp_get_connection_count(struct evhttp* http); + +/** Set the value to use for the Content-Type header when none was provided. If the content type string is NULL, the Content-Type header will not be automatically added. |