-
Notifications
You must be signed in to change notification settings - Fork 38
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
fight big buffers #66
base: develop
Are you sure you want to change the base?
Conversation
@@ -427,7 +427,8 @@ get_request_(Socket, Buffer, Options, {Mod, Args} = Callback) -> | |||
exit(normal) | |||
end. | |||
|
|||
recv_request(Socket, Buffer, Options, {Mod, Args} = _Callback) -> | |||
recv_request(Socket, Buffer, Options, {Mod, Args} = Callback) -> | |||
ok = check_max_buffer_size(Socket, Buffer, Options, Callback, 414), |
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.
Might be a good idea to make check_max_size
function a bit more generic and apply it in all three cases (request line, headers, body)
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 max_body_size
option might be renamed to soft_max_request_size
. Or introduce max_headers_size
, max_request_lint_size
(this one can be hardcoded though).
handle_event(Mod, bad_request, [{request_line_size, BufferSize}], Args) | ||
end, | ||
|
||
case MaxSize * 2 > BufferSize of |
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.
Can't understand why a response is sent even for "way_too_big..." (in tests) requests
way_too_big_headers() -> | ||
CookieHeader = {"Cookie", binary:copy(<<"a">>, 1024 * 2200)}, | ||
Headers = [CookieHeader], | ||
?assertMatch({error, closed}, |
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 why it doesn't work ...
[{active, false}, binary]), | ||
Req = <<"GET /", Path/binary, " HTTP/1.1\r\n">>, | ||
gen_tcp:send(Socket, Req), | ||
?assertMatch({error, closed}, gen_tcp:recv(Socket, 0)). |
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.
here, just as in way_too_big_headers
, a response is sent back even though the socket should just be closed, without any response
[{active, false}, binary]), | ||
Req = <<"GET /", Path/binary, " HTTP/1.1\r\n">>, | ||
gen_tcp:send(Socket, Req), | ||
?assertMatch({ok, <<"HTTP/1.1 414 Request-URI Too Long\r\n" |
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.
Isn't the reason line just "URI Too Long" (without "Request" part)?
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.
Same for 413 Payload Too Large
#65