File chatterbox-0.5.0-git.patch of Package chatterbox

diff --git a/src/h2_connection.erl b/src/h2_connection.erl
index 25ad96a..b079cbe 100644
--- a/src/h2_connection.erl
+++ b/src/h2_connection.erl
@@ -29,6 +29,7 @@
          get_peercert/1,
          get_streams/1,
          send_window_update/2,
+         update_settings/2,
          send_frame/2
         ]).
 
@@ -294,6 +295,10 @@ get_streams(Pid) ->
 send_window_update(Pid, Size) ->
     gen_fsm:send_all_state_event(Pid, {send_window_update, Size}).
 
+-spec update_settings(pid(), h2_frame_settings:payload()) -> ok.
+update_settings(Pid, Payload) ->
+    gen_fsm:send_all_state_event(Pid, {update_settings, Payload}).
+
 -spec stop(pid()) -> ok.
 stop(Pid) ->
     gen_fsm:send_all_state_event(Pid, stop).
@@ -925,6 +930,12 @@ handle_event({send_window_update, Size},
      Conn#connection{
        recv_window_size=CRWS+Size
       }};
+handle_event({update_settings, Http2Settings},
+             StateName,
+             #connection{}=Conn) ->
+    {next_state,
+     StateName,
+     send_settings(Http2Settings, Conn)};
 handle_event({send_headers, StreamId, Headers, Opts},
              StateName,
              #connection{
diff --git a/src/h2_frame_settings.erl b/src/h2_frame_settings.erl
index 9dbe78a..a8cced6 100644
--- a/src/h2_frame_settings.erl
+++ b/src/h2_frame_settings.erl
@@ -102,6 +102,10 @@ parse_settings(<<0,5,Val:4/binary,T/binary>>, S) ->
     parse_settings(T, [{?SETTINGS_MAX_FRAME_SIZE, binary:decode_unsigned(Val)}|S]);
 parse_settings(<<0,6,Val:4/binary,T/binary>>, S)->
     parse_settings(T, [{?SETTINGS_MAX_HEADER_LIST_SIZE, binary:decode_unsigned(Val)}|S]);
+% An endpoint that receives a SETTINGS frame with any unknown or unsupported identifier 
+% MUST ignore that setting
+parse_settings(<<_:6/binary,T/binary>>, S)->
+    parse_settings(T, S);
 parse_settings(<<>>, Settings) ->
     Settings.
 
diff --git a/src/h2_stream_set.erl b/src/h2_stream_set.erl
index 8f69e3d..501512c 100644
--- a/src/h2_stream_set.erl
+++ b/src/h2_stream_set.erl
@@ -146,7 +146,9 @@
     my_active_count/1,
     their_active_count/1,
     my_active_streams/1,
-    their_active_streams/1
+    their_active_streams/1,
+    my_max_active/1,
+    their_max_active/1
    ]
   ).
 
@@ -745,7 +747,7 @@ s_send_what_we_can(SWS, MFS, #active_stream{}=Stream) ->
         stream ->
             {SWS - SentBytes, NewS};
         connection ->
-            {0, NewS}
+            {SWS - SentBytes, NewS}
     end;
 s_send_what_we_can(SWS, _MFS, NonActiveStream) ->
     {SWS, NonActiveStream}.
@@ -861,3 +863,14 @@ my_active_streams(SS) ->
 -spec their_active_streams(stream_set()) -> [stream()].
 their_active_streams(SS) ->
     SS#stream_set.theirs#peer_subset.active.
+
+%% My MCS (max_active)
+-spec my_max_active(stream_set()) -> non_neg_integer().
+my_max_active(SS) ->
+    SS#stream_set.mine#peer_subset.max_active.
+
+%% Their MCS (max_active)
+-spec their_max_active(stream_set()) -> non_neg_integer().
+their_max_active(SS) ->
+    SS#stream_set.theirs#peer_subset.max_active.
+
diff --git a/test/http2_spec_6_5_SUITE.erl b/test/http2_spec_6_5_SUITE.erl
index d247105..a30569e 100644
--- a/test/http2_spec_6_5_SUITE.erl
+++ b/test/http2_spec_6_5_SUITE.erl
@@ -8,6 +8,7 @@
 all() ->
     [
      sends_invalid_push_setting,
+     sends_unknown_settings_frame,
      sends_value_above_max_flow_control_window_size,
      sends_max_frame_size_too_small,
      sends_max_frame_size_too_big
@@ -37,6 +38,21 @@ sends_invalid_push_setting(_Config) ->
     ?assertEqual(?PROTOCOL_ERROR, (h2_frame_goaway:error_code(GoAway))),
     ok.
 
+sends_unknown_settings_frame(_Config) ->
+    {ok, Client} = http2c:start_link(),
+
+    Bin = <<16#00,16#00,16#06,16#04,16#00,16#00,16#00,16#00,16#00,
+            16#254,16#03,16#00,16#00,16#00,16#01>>,
+    http2c:send_binary(Client, Bin),
+
+    Resp = http2c:wait_for_n_frames(Client, 0, 1),
+    ct:pal("Resp: ~p", [Resp]),
+    ?assertEqual(1, (length(Resp))),
+    [{Header, Payload}] = Resp,
+    ?assertEqual(?SETTINGS, (Header#frame_header.type)),
+    ?assertEqual({settings, []}, (Payload)),
+    ok.
+
 sends_value_above_max_flow_control_window_size(_Config) ->
     {ok, Client} = http2c:start_link(),
     Bin = <<16#00,16#00,16#06,16#04,16#00,16#00,16#00,16#00,16#00,
openSUSE Build Service is sponsored by