aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenedikt Reinartz <[email protected]>2021-07-02 17:55:53 +0200
committerLoïc Hoguin <[email protected]>2022-08-30 14:53:53 +0200
commit1f42d14e88fe028295a66878140750fee0f93892 (patch)
tree01f75a48a7923cf5c00fdff6dc549f5bfcbb5710
parentad6302f51092009de5b1d4481ef2bfcd4091a257 (diff)
downloadgun-1f42d14e88fe028295a66878140750fee0f93892.tar.gz
gun-1f42d14e88fe028295a66878140750fee0f93892.tar.bz2
gun-1f42d14e88fe028295a66878140750fee0f93892.zip
Ignore parameters for text/event-stream
-rw-r--r--src/gun_sse_h.erl12
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.