Compressing HTTP Post Data sent from browser

前端 未结 3 1750
故里飘歌
故里飘歌 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 03:05

    Just achieved this using https://github.com/dankogai/js-deflate However the postdata for whatever reason will strip the + signs and replace them with spaces.

    To send the data via javascript:

    params.mapdata=  btoa(RawDeflate.deflate(JSON.stringify(mapdata)));
    

    To receive the data via php:

    $value = gzinflate(base64_decode(preg_replace('/\s/', '+',$value)));
    

提交回复
热议问题