diff options
author | Benedikt Reinartz <[email protected]> | 2021-07-02 17:55:53 +0200 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2022-08-30 14:53:53 +0200 |
commit | 1f42d14e88fe028295a66878140750fee0f93892 (patch) | |
tree | 01f75a48a7923cf5c00fdff6dc549f5bfcbb5710 /src | |
parent | ad6302f51092009de5b1d4481ef2bfcd4091a257 (diff) | |
download | gun-1f42d14e88fe028295a66878140750fee0f93892.tar.gz gun-1f42d14e88fe028295a66878140750fee0f93892.tar.bz2 gun-1f42d14e88fe028295a66878140750fee0f93892.zip |
Ignore parameters for text/event-stream
Diffstat (limited to 'src')
-rw-r--r-- | src/gun_sse_h.erl | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/gun_sse_h.erl b/src/gun_sse_h.erl index 729fc66..c53fada 100644 --- a/src/gun_sse_h.erl +++ b/src/gun_sse_h.erl @@ -25,15 +25,19 @@ }). %% @todo In the future we want to allow different media types. -%% @todo For text/event-stream specifically, the parameters must be ignored. -spec init(pid(), reference(), _, cow_http:headers(), _) -> {ok, #state{}} | disable. init(ReplyTo, StreamRef, _, Headers, _) -> case lists:keyfind(<<"content-type">>, 1, Headers) of - {_, <<"text/event-stream">>} -> - {ok, #state{reply_to=ReplyTo, stream_ref=StreamRef, - sse_state=cow_sse:init()}}; + {_, ContentType} -> + case cow_http_hd:parse_content_type(ContentType) of + {<<"text">>, <<"event-stream">>, _Ignored} -> + {ok, #state{reply_to=ReplyTo, stream_ref=StreamRef, + sse_state=cow_sse:init()}}; + _ -> + disable + end; _ -> disable end. |