aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/cow_http2.erl22
1 files changed, 15 insertions, 7 deletions
diff --git a/src/cow_http2.erl b/src/cow_http2.erl
index 9e798c5..07d09c8 100644
--- a/src/cow_http2.erl
+++ b/src/cow_http2.erl
@@ -367,13 +367,21 @@ rst_stream(StreamID, Reason) ->
ErrorCode = error_code(Reason),
<< 4:24, 3:8, 0:9, StreamID:31, ErrorCode:32 >>.
-%% @todo Actually implement it. :-)
-settings(#{}) ->
- << 0:24, 4:8, 0:40 >>.
-
-%% @todo Actually implement it. :-)
-settings_payload(#{}) ->
- <<>>.
+settings(Settings) ->
+ Payload = settings_payload(Settings),
+ Len = iolist_size(Payload),
+ [<< Len:24, 4:8, 0:40 >>, Payload].
+
+settings_payload(Settings) ->
+ [case Key of
+ header_table_size -> <<1:16, Value:32>>;
+ enable_push when Value -> <<2:16, 1:32>>;
+ enable_push -> <<2:16, 0:32>>;
+ max_concurrent_streams -> <<3:16, Value:32>>;
+ initial_window_size -> <<4:16, Value:32>>;
+ max_frame_size -> <<5:16, Value:32>>;
+ max_header_list_size -> <<6:16, Value:32>>
+ end || {Key, Value} <- maps:to_list(Settings)].
settings_ack() ->
<< 0:24, 4:8, 1:8, 0:32 >>.