From 1f42d14e88fe028295a66878140750fee0f93892 Mon Sep 17 00:00:00 2001 From: Benedikt Reinartz Date: Fri, 2 Jul 2021 17:55:53 +0200 Subject: Ignore parameters for text/event-stream --- src/gun_sse_h.erl | 12 ++++++++---- 1 file 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. -- cgit v1.2.3