Access Chrome's internal gzip routine from Jav

2019-06-16 07:24发布

All modern browsers include gzip routines for exchanging compressed data with servers. Can anyone point me in the right direction for writing a Chrome extension that would allow Javascript to leverage this routine?

I would like to compress some data in Javascript before sending it to the server over a WebSocket, and Chrome's built in deflate routine would certainly be faster than anything I could write in Javascript.

2条回答
你好瞎i
2楼-- · 2019-06-16 07:33

If a javascript implementation isn't fast enough for you, you could use native client.

You would use some gzip library in c/c++, and write the glue code so javascript can call it through native client. It should be near or equal to the speed you would get from calling chrome's internal routine were that possible.

查看更多
爷、活的狠高调
3楼-- · 2019-06-16 07:42

Based on this answer to a Stack Overflow question, manually applying gzip to a WebSocket is completely unnecessary. As of version 19, Chrome will apparently compress WebSocket traffic automatically when the server supports it.

查看更多
登录 后发表回答