aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2017-11-27 22:47:55 +0100
committerLoïc Hoguin <[email protected]>2017-11-27 22:47:55 +0100
commit4cd81db0b11ba0305bab9cc98dfe2264cf88b362 (patch)
treeef83a71e0cf1125b6132710dc4b18cd4a6bd86b6
parenta09bf2778d0a1e32c57f0e79d609b3a0ace3273e (diff)
downloadcowlib-4cd81db0b11ba0305bab9cc98dfe2264cf88b362.tar.gz
cowlib-4cd81db0b11ba0305bab9cc98dfe2264cf88b362.tar.bz2
cowlib-4cd81db0b11ba0305bab9cc98dfe2264cf88b362.zip
Implement the building of h2 SETTINGS frames
-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 >>.