nayyarkhanarain / pywebsocket

Automatically exported from code.google.com/p/pywebsocket
0 stars 0 forks source link

Compression for WebSocket #69

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Hi,

Does pywebsocket support gzip compression of the HTTP packets?
Gzip compression is necessary if pywebsocket should replace my 
current AJAX-solution. If so, how do I configure it?

Regards,
Andreas R.

Original issue reported on code.google.com by andre...@pvv.ntnu.no on 23 Oct 2010 at 11:48

GoogleCodeExporter commented 8 years ago
Gzip cannot be performed on websockets at least not in the same way they are 
performed for standard HTTP, this is because the the end of a message does not 
terminate the connection.  It might be possible to implement compression of 
individual messages sent over the websocket but then the end consumer (likely 
your JS code on a webpage) would need to know how to uncompress those messages 
itself.  In essence you would have to perform the compression before the 
message is received by pywebsocket and after it is received by the consumer 
application (likely a browser.)

Google might be kind enough to implement this kind of functionality within 
the/a project but would also have to include a JS library to take care of the 
client end operations (which would be pretty well out of band for the 
intentions of this project as it is entirely focused on server side solutions.) 
 Searching the code base quickly I see that the only reference to "gzip" is 
within examples of bad request headers in the test suite meaning that this 
feature wasn't just overlooked.

I am not a member of this project so I can't say for sure, but I doubt this is 
going to happen and it is by no means a defect, but rather you are making a 
feature request.

I'm not seeing that this kind of JS library has been implemented before but 
some alternatives are discussed in a similar question at: 
http://stackoverflow.com/questions/294297/javascript-implementation-of-gzip

Regards,
Beau Breon

Original comment by bbr...@gmail.com on 22 Nov 2010 at 12:16

GoogleCodeExporter commented 8 years ago
Now the spec draft includes deflate-stream extension that applies deflate, the 
compression used by gzip, to entire WebSocket stream after opening handshake. 
Certain flush algorithm, maybe Z_SYNC_FLUSH, would be explicitly specified to 
be used to make each frame immediately un-compressible, but not yet.

pywebsocket is planned to support deflate-stream on the next release with the 
latest protocol implementation.

Original comment by tyoshino@chromium.org on 25 Feb 2011 at 2:01

GoogleCodeExporter commented 8 years ago
deflate-stream support has been added by this CL.
http://code.google.com/p/pywebsocket/source/detail?r=429
Once the protocol is stable enough, you can try it.

WebSocket core specification is becoming stable recently. Please watch this 
issue to track our status of updating pywebsocket to latest spec.
http://code.google.com/p/pywebsocket/issues/detail?id=66

Original comment by tyoshino@chromium.org on 15 Apr 2011 at 6:51

GoogleCodeExporter commented 8 years ago
We've been proposing an alternative compression method called deflate-frame 
http://tools.ietf.org/html/draft-tyoshino-hybi-websocket-perframe-deflate . 
It's already implemented in pywebsocket. It's not standardized yet, but we'll 
continue getting this implemented, tested and reviewed. Please track the status 
of standardization at HyBi working group 
https://www.ietf.org/mailman/listinfo/hybi and pywebsocket implementation 
status by release notes.

Original comment by tyoshino@chromium.org on 7 Dec 2011 at 4:06