eventsource icon indicating copy to clipboard operation
eventsource copied to clipboard

Support Accept-Encoding: gzip

Open jpillora opened this issue 6 years ago • 6 comments

Streaming text data (Event-source) is a perfect candidate for gzip. It would be awesome if this module supported gzip.

It can be enabled by default safely:

  • Announce gzip support with the Accept-Encoding header
  • Only decompress the response if the server responds with Content-Encoding: gzip

See https://stackoverflow.com/a/14739453/977939.

jpillora avatar Sep 21 '17 01:09 jpillora

Does EventSource specification support GZip compression? If not, you stil can do the compression yourself...

piranna avatar Sep 21 '17 07:09 piranna

True, it's not in the spec though all browsers support it, so it's more of a nice-to-have - can close if not interested :+1:

On Thu, 21 Sep 2017 at 17:01 Jesús Leganés-Combarro < [email protected]> wrote:

Does EventSource specification support GZip compression? If not, you stil can do the compression yourself...

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/EventSource/eventsource/issues/86#issuecomment-331070075, or mute the thread https://github.com/notifications/unsubscribe-auth/AAmr80QkpSVgEhkjWCvlSGVUIUepG1yyks5skgnNgaJpZM4PeshZ .

jpillora avatar Sep 21 '17 08:09 jpillora

all browsers support it

Have you done any test for that? I know brosers adds the header, but if it works with EventSource requests, it would be interesting to implement it...

piranna avatar Sep 21 '17 08:09 piranna

See https://velox.jpillora.com/ and open Dev Tools (this server is written in Go):

screen shot 2017-09-21 at 10 59 21 pm

Definitely supported in Chrome and Firefox, haven't tested IE and others though can't imagine why they also wouldn't work

jpillora avatar Sep 21 '17 13:09 jpillora

The EventSource protocol is built on top of the HTTP protocol, so if gzip is supported in HTTP (it is), that makes it implicitly supported in EventSource too, doesn't it?

aslakhellesoy avatar Sep 21 '17 13:09 aslakhellesoy

The EventSource protocol is built on top of the HTTP protocol, so if gzip is supported in HTTP (it is), that makes it implicitly supported in EventSource too, doesn't it?

I think so, just only it seemsed to me to be a corner case and wanted to confirm if it actually worked. Having confirmed that, pull-requests are welcome :-) I think it can be checked and done directly and explicitly, or maybe by using gunzip-maybe, but it could add some boilerplate, too.

piranna avatar Sep 21 '17 13:09 piranna