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

Hibernate and more #1667

Closed
wants to merge 5 commits into from
Closed
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Use maps:fold for cowboy_http's set_options for code clarity
  • Loading branch information
essen committed Feb 7, 2025
commit 9c622009c0da6079a080584df1d5e6526cb2bc7d
23 changes: 8 additions & 15 deletions src/cowboy_http.erl
Original file line number Diff line number Diff line change
Expand Up @@ -1266,21 +1266,14 @@ commands(State0=#state{ref=Ref, parent=Parent, socket=Socket, transport=Transpor
Protocol:takeover(Parent, Ref, Socket, Transport,
opts_for_upgrade(State), Buffer, InitialState);
%% Set options dynamically.
commands(State0=#state{overriden_opts=Opts},
StreamID, [{set_options, SetOpts}|Tail]) ->
State1 = case SetOpts of
#{idle_timeout := IdleTimeout} ->
set_timeout(State0#state{overriden_opts=Opts#{idle_timeout => IdleTimeout}},
idle_timeout);
_ ->
State0
end,
State = case SetOpts of
#{chunked := Chunked} ->
State1#state{overriden_opts=Opts#{chunked => Chunked}};
_ ->
State1
end,
commands(State0, StreamID, [{set_options, SetOpts}|Tail]) ->
State = maps:fold(fun
(chunked, Chunked, StateF=#state{overriden_opts=Opts}) ->
StateF#state{overriden_opts=Opts#{chunked => Chunked}};
(idle_timeout, IdleTimeout, StateF=#state{overriden_opts=Opts}) ->
set_timeout(StateF#state{overriden_opts=Opts#{idle_timeout => IdleTimeout}},
idle_timeout)
end, State0, SetOpts),
commands(State, StreamID, Tail);
%% Stream shutdown.
commands(State, StreamID, [stop|Tail]) ->
Expand Down