diff --git a/src/httplib_config_options.c b/src/httplib_config_options.c index 756f8047..fd1938a2 100644 --- a/src/httplib_config_options.c +++ b/src/httplib_config_options.c @@ -37,7 +37,6 @@ struct httplib_option XX_httplib_config_options[] = { { "cgi_interpreter", CONFIG_TYPE_FILE, NULL }, { "authentication_domain", CONFIG_TYPE_STRING, "example.com" }, { "ssi_pattern", CONFIG_TYPE_EXT_PATTERN, "**.shtml$|**.shtm$" }, - { "throttle", CONFIG_TYPE_STRING, NULL }, { "global_auth_file", CONFIG_TYPE_FILE, NULL }, { "index_files", CONFIG_TYPE_STRING, "index.xhtml,index.html,index.htm,index.cgi,index.shtml,index.php" }, { "access_control_list", CONFIG_TYPE_STRING, NULL }, diff --git a/src/httplib_free_context.c b/src/httplib_free_context.c index ecf49681..432b352f 100644 --- a/src/httplib_free_context.c +++ b/src/httplib_free_context.c @@ -92,6 +92,7 @@ void XX_httplib_free_context( struct httplib_context *ctx ) { if ( ctx->protect_uri != NULL ) { httplib_free( ctx->protect_uri ); ctx->protect_uri = NULL; } if ( ctx->run_as_user != NULL ) { httplib_free( ctx->run_as_user ); ctx->run_as_user = NULL; } if ( ctx->ssl_cipher_list != NULL ) { httplib_free( ctx->ssl_cipher_list ); ctx->ssl_cipher_list = NULL; } + if ( ctx->throttle != NULL ) { httplib_free( ctx->throttle ); ctx->throttle = NULL; } for (i = 0; i < NUM_OPTIONS; i++) { diff --git a/src/httplib_handle_request.c b/src/httplib_handle_request.c index 6e1592b3..34a8ab22 100644 --- a/src/httplib_handle_request.c +++ b/src/httplib_handle_request.c @@ -149,7 +149,7 @@ void XX_httplib_handle_request( struct httplib_connection *conn ) { * 3. if this ip has limited speed, set it for this connection */ - conn->throttle = XX_httplib_set_throttle( conn->ctx->cfg[THROTTLE], XX_httplib_get_remote_ip( conn ), ri->local_uri ); + conn->throttle = XX_httplib_set_throttle( conn->ctx->throttle, XX_httplib_get_remote_ip( conn ), ri->local_uri ); /* * 4. call a "handle everything" callback, if registered diff --git a/src/httplib_main.h b/src/httplib_main.h index 7cf869cb..2af215f4 100644 --- a/src/httplib_main.h +++ b/src/httplib_main.h @@ -396,7 +396,6 @@ enum { CGI_INTERPRETER, AUTHENTICATION_DOMAIN, SSI_EXTENSIONS, - THROTTLE, GLOBAL_PASSWORDS_FILE, INDEX_FILES, ACCESS_CONTROL_LIST, @@ -595,6 +594,7 @@ struct httplib_context { char * protect_uri; char * run_as_user; char * ssl_cipher_list; + char * throttle; int num_threads; int request_timeout; diff --git a/src/httplib_start.c b/src/httplib_start.c index 277ff663..af413f5d 100644 --- a/src/httplib_start.c +++ b/src/httplib_start.c @@ -303,6 +303,7 @@ static bool process_options( struct httplib_context *ctx, const struct httplib_o ctx->ssl_verify_paths = true; ctx->ssl_verify_peer = false; ctx->static_file_max_age = 0; + ctx->throttle = NULL; ctx->tcp_nodelay = false; ctx->websocket_timeout = 30000; @@ -327,6 +328,7 @@ static bool process_options( struct httplib_context *ctx, const struct httplib_o if ( check_bool( ctx, options, "ssl_verify_paths", & ctx->ssl_verify_paths ) ) return true; if ( check_bool( ctx, options, "ssl_verify_peer", & ctx->ssl_verify_peer ) ) return true; if ( check_int( ctx, options, "static_file_max_age", & ctx->static_file_max_age, 0, INT_MAX ) ) return true; + if ( check_str( ctx, options, "throttle", & ctx->throttle ) ) return true; if ( check_bool( ctx, options, "tcp_nodelay", & ctx->tcp_nodelay ) ) return true; if ( check_int( ctx, options, "websocket_timeout", & ctx->websocket_timeout, 0, INT_MAX ) ) return true;