Skip to content

Commit

Permalink
Tweak the MIME comparison in EventSource
Browse files Browse the repository at this point in the history
MIME parameters should not be inspected when checking for text/event-stream.
  • Loading branch information
nox committed Jan 14, 2019
1 parent bec1c39 commit 8611b0f
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions components/script/dom/eventsource.rs
Expand Up @@ -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
{
self.origin = meta.final_url.origin().ascii_serialization();
self.announce_the_connection();
} else {
self.fail_the_connection()
}
},
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();
},
Err(_) => {
self.reestablish_the_connection();
Expand Down

0 comments on commit 8611b0f

Please sign in to comment.