From bbb6e57123ca12ad18e88f4a6e28b866afa3ed5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Thu, 27 Feb 2020 11:41:05 +0100 Subject: 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. --- src/cow_http2_machine.erl | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/cow_http2_machine.erl b/src/cow_http2_machine.erl index 3b7cd10..a88d9f1 100644 --- a/src/cow_http2_machine.erl +++ b/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 -- cgit v1.2.3