Compressing HTTP Post Data sent from browser

前端 未结 3 1751
故里飘歌
故里飘歌 2020-11-30 02:24

I want to send a compressed POST data with Javascript to a server I control. Is there any way to let the HTTP layer deal with the compression.

I\'m sending JSON. If

3条回答
  •  北海茫月
    2020-11-30 02:48

    It's possible, but I would recommend strongly against accepting gzipped data incoming to your server. The main reason is to prevent your server from getting gzip bombed. It's generally not possible to know what the uncompressed data looks like before actually uncompressing it, so a user could send you a web request that looks like a harmless 1 KB or 1 MB of data but is really 100 GB of data, and then your web server (nginx or apache) hangs the next 10 minutes trying to decompress it all, eventually running out of memory/locking up.

提交回复
热议问题