Tweak the MIME comparison in EventSource

MIME parameters should not be inspected when checking for text/event-stream.
This commit is contained in:
Anthony Ramine 2019-01-12 20:15:51 +01:00
parent bec1c396de
commit 8611b0f8c4

View file

@ -344,19 +344,15 @@ impl FetchResponseListener for EventSourceContext {
FetchMetadata::Unfiltered(m) => m,
FetchMetadata::Filtered { unsafe_, .. } => unsafe_,
};
match meta.content_type {
None => self.fail_the_connection(),
Some(ct) => {
if <ContentType as Into<Mime>>::into(ct.into_inner()) ==
mime::TEXT_EVENT_STREAM
{
let mime = match meta.content_type {
None => return self.fail_the_connection(),
Some(ct) => <ContentType as Into<Mime>>::into(ct.into_inner()),
};
if (mime.type_(), mime.subtype()) != (mime::TEXT, mime::EVENT_STREAM) {
return self.fail_the_connection();
}
self.origin = meta.final_url.origin().ascii_serialization();
self.announce_the_connection();
} else {
self.fail_the_connection()
}
},
}
},
Err(_) => {
self.reestablish_the_connection();