O'Reilly logo

Developing RESTful Services with JAX-RS 2.0, WebSockets, and JSON by Bhakti Mehta, Masoud Kalali

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Best practices for applications based on Server-sent Events

The following chapter covers the best practices for applications based on Server-sent Events. The following topics will be covered:

  • Checking if the event source's origin is as expected
  • Working with proxy servers and Server-sent Events
  • Handling fault tolerance for Server-sent Events

Checking if the event source's origin is as expected

The following snippet shows how to check for the origin of the event source so that it matches the application's origin.

if (e.origin != 'http://foo.com') {
alert('Origin was not http://foo.com');
return;

An event stream from an origin distinct from the origin of the content consuming the event stream can result in information leakage. When the events are obtained ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required