Skip to content

add option for max request content length #221

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

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/socketify/native.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@
void uws_add_server_name_with_options(int ssl, uws_app_t *app, const char *hostname_pattern, size_t hostname_pattern_length, struct us_socket_context_options_t options);
void uws_missing_server_name(int ssl, uws_app_t *app, uws_missing_server_handler handler, void *user_data);
void uws_filter(int ssl, uws_app_t *app, uws_filter_handler handler, void *user_data);
void uws_set_max_content_length(uws_app_t *app, size_t maxContentLength);

void uws_res_close(int ssl, uws_res_t *res);
void uws_res_end(int ssl, uws_res_t *res, const char *data, size_t length, bool close_connection);
Expand Down
3 changes: 2 additions & 1 deletion src/socketify/socketify.py
Original file line number Diff line number Diff line change
Expand Up @@ -2618,6 +2618,7 @@ def __init__(
task_factory_max_items=100_000,
lifespan=True,
idle_relaxation_time=0.01,
max_content_length=0,
):

socket_options_ptr = ffi.new("struct us_socket_context_options_t *")
Expand Down Expand Up @@ -2688,7 +2689,6 @@ def __init__(
socket_options.ssl_prefer_low_memory_usage = ffi.cast(
"int", options.ssl_prefer_low_memory_usage
)

else:
self.is_ssl = False
self.SSL = ffi.cast("int", 0)
Expand All @@ -2706,6 +2706,7 @@ def __init__(
self._ptr = ffi.new_handle(self)
if bool(lib.uws_constructor_failed(self.SSL, self.app)):
raise RuntimeError("Failed to create connection")
lib.uws_set_max_content_length(self.app, max_content_length)

self.handlers = []
self.error_handler = None
Expand Down