diff options
author | Loïc Hoguin <[email protected]> | 2020-02-27 16:27:34 +0100 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2020-02-27 16:27:34 +0100 |
commit | f0b64ece629e66590d2f6964d3f3102fc1cf11b8 (patch) | |
tree | 0537422743967df3d241cff18b26b17032c06dfb /src | |
parent | 85c1fea6ff5d82d3a6cdd8f13c9d292e4df90894 (diff) | |
download | gun-f0b64ece629e66590d2f6964d3f3102fc1cf11b8.tar.gz gun-f0b64ece629e66590d2f6964d3f3102fc1cf11b8.tar.bz2 gun-f0b64ece629e66590d2f6964d3f3102fc1cf11b8.zip |
Use specific error when HTTP/2 receives HTTP/1 response
Diffstat (limited to 'src')
-rw-r--r-- | src/gun_http2.erl | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/gun_http2.erl b/src/gun_http2.erl index 3587466..64850fa 100644 --- a/src/gun_http2.erl +++ b/src/gun_http2.erl @@ -163,8 +163,13 @@ parse(Data, State0=#http2_state{status=preface, http2_machine=HTTP2Machine}, %% Any error in the preface is converted to this specific error %% to make debugging the problem easier (it's the server's fault). _ -> - {connection_error(State0, {connection_error, protocol_error, - 'Invalid connection preface received. (RFC7540 3.5)'}), EvHandlerState0} + Reason = case Data of + <<"HTTP/1",_/bits>> -> + 'Invalid connection preface received. Appears to be an HTTP/1 response? (RFC7540 3.5)'; + _ -> + 'Invalid connection preface received. (RFC7540 3.5)' + end, + {connection_error(State0, {connection_error, protocol_error, Reason}), EvHandlerState0} end; parse(Data, State0=#http2_state{status=Status, http2_machine=HTTP2Machine, streams=Streams}, EvHandler, EvHandlerState0) -> |