Skip to content
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

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open

fight big buffers #66

wants to merge 1 commit into from

Conversation

ghost
Copy link

@ghost ghost commented Aug 13, 2018

#65

@@ -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),
Copy link
Author

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)

Copy link
Author

@ghost ghost Aug 13, 2018

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
Copy link
Author

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},
Copy link
Author

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)).
Copy link
Author

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"
Copy link
Author

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)?

https://tools.ietf.org/html/rfc7231#section-6.5.12

Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

0 participants