Skip to content

Commit

Permalink
Usage of native EventSource in Chrome and Firefox
Browse files Browse the repository at this point in the history
Usage of native EventSource in Chrome and Firefox
  • Loading branch information
Yaffle committed Dec 8, 2014
1 parent bd58f15 commit 1b85c03
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion eventsource.js
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,21 @@
EventSource.prototype = new F();
F.call(EventSource);

if (Transport !== undefined) {
var isEventSourceSupported = function () {
if (global.EventSource !== undefined) {
try {
var es = new global.EventSource("data:text/event-stream;charset=utf-8,");
es.close();
return es.withCredentials === false &&
es.url !== ""; // to filter out Opera 12 implementation
} catch (error) {
throwError(error);
}
}
return false;
};

if (Transport !== undefined && !isEventSourceSupported()) {
// Why replace a native EventSource ?
// https://bugzilla.mozilla.org/show_bug.cgi?id=444328
// https://bugzilla.mozilla.org/show_bug.cgi?id=831392
Expand Down

0 comments on commit 1b85c03

Please sign in to comment.