Browse Source

Clarify error when expecting a SETTINGS frame in HTTP/2 preface

The error was appropriate for server mode, but not for client
mode, because the server does not send the preface sequence.
Loïc Hoguin 5 years ago
parent
commit
bbb6e57123
1 changed files with 5 additions and 1 deletions
  1. 5 1
      src/cow_http2_machine.erl

+ 5 - 1
src/cow_http2_machine.erl

@@ -830,9 +830,13 @@ settings_frame({settings, Settings}, State0=#http2_machine{
 		_ -> {ok, State2}
 	end;
 %% We expect to receive a SETTINGS frame as part of the preface.
-settings_frame(_F, State) ->
+settings_frame(_F, State=#http2_machine{mode=server}) ->
 	{error, {connection_error, protocol_error,
 		'The preface sequence must be followed by a SETTINGS frame. (RFC7540 3.5)'},
+		State};
+settings_frame(_F, State) ->
+	{error, {connection_error, protocol_error,
+		'The preface must begin with a SETTINGS frame. (RFC7540 3.5)'},
 		State}.
 
 %% When SETTINGS_INITIAL_WINDOW_SIZE changes we need to update