mirror of
https://github.com/ninenines/cowboy.git
synced 2025-07-15 04:30:25 +00:00
Add max_frame_size option for websocket handlers
Option allows to limit a frame by size before decoding its payload. LH: I have added a test for when the limit is reached on a nofin fragmented frame (the last commit addressed that case but it had no test). I have fixed formatting and other, and changed the default value to infinity since it might otherwise be incompatible with existing code. I also added documentation and a bunch of other minor changes.
This commit is contained in:
parent
288deb5b88
commit
4c34774b7e
5 changed files with 105 additions and 8 deletions
|
@ -225,6 +225,22 @@ init(Req, State) ->
|
|||
This value cannot be changed once it is set. It defaults to
|
||||
`60000`.
|
||||
|
||||
=== Limiting frame sizes
|
||||
|
||||
Cowboy accepts frames of any size by default. You should
|
||||
limit the size depending on what your handler may handle.
|
||||
You can do this via the `init/2` callback:
|
||||
|
||||
[source,erlang]
|
||||
----
|
||||
init(Req, State) ->
|
||||
{cowboy_websocket, Req, State, #{
|
||||
max_frame_size => 8000000}}.
|
||||
----
|
||||
|
||||
The lack of limit is historical. A future version of
|
||||
Cowboy will have a more reasonable default.
|
||||
|
||||
=== Saving memory
|
||||
|
||||
The Websocket connection process can be set to hibernate
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue