youngmonkeys / ezyfox-server

A socket server (include SSL) supports realtime application, realtime game, MMORPG, messaging, chat and streaming data with TCP, UDP and Websocket
Apache License 2.0
569 stars 98 forks source link

Use gzip to zip request response #114

Open tvd12 opened 1 year ago

tvd12 commented 1 year ago

zip request, response has size > 1500 bytes

anaconda875 commented 6 months ago

In http, we have Content-Encoding, Accept-Encoding headers to decide whether we should compress/uncompress the data and the codec to do that (gzip is a case). Is there any equivalent in Socket? I think we should not force user using gzip or 1500b threshold, they can choose deflate, gzip, identity based on their need. Just provide them a configuration and let them decide which is best for them

tvd12 commented 6 months ago

@anaconda875

  1. No, it's depending header of package, you can take a look here.
  2. yes, gzip should be optional.
anaconda875 commented 6 months ago

So please consider this simple scenario: Add one more bit to req header: respCompressionRequired default false. If true, server will use gzip to compress resp (only gzip), don't care about 1500bytes. Add one more bit isCompressed to resp header. In client sdk, add 2 configuration: