diff options
-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. |