Reactive-Extensions / RxJS-DOM

HTML DOM Bindings for the Reactive Extensions for JavaScript
http://reactivex.io
Other
438 stars 101 forks source link

Set headers in 'fromEventSource' #116

Closed jufmejiagu closed 8 years ago

jufmejiagu commented 8 years ago

Hi.

I try to set the header in a fromEventSource for a lot of hours... I could not do it. If this it's possible, we need more documentation... If not it's possible, It would be very interesting to do for security reasons. Event source not have API from http headers, it is possible?

Thanks!!

whiteinge commented 8 years ago

The EventSource specification itself does not describe adding custom headers.

For things like cookies, http-auth, or CORS, EventSource will transparently use those like any other HTTP request for the given server. (CORS support was missing in the early days but all evergreen browsers that support EventSource should also support CORS now.) Sometimes that means you must first make a non-EventSource connection to that server before making the EventSource connection.

For truly custom behavior the usual approach is to pass that info via a query string in the URL; of course this requires server-side support.

jufmejiagu commented 8 years ago

Yes, i used the query string in the URL. But we were looking for another way to do... Thanks.