简体   繁体   中英

Empty content from gziped http response

I have implemented gziping content of response in a filter. If server is sending 200 response without any content is still adding content encoding header like

Content-Encoding:gzip
Content-Length:0

On the other side another filter is reading the response and is trying to create GZIPInputStream which will fail because content does not contain gzip header and footer. Question is which side is doing it wrong? Should producer not add "Content-Encoding:gzip"? Should producer add gzip header/footer to content? Or maybe should consumer recognize empty content and don't try to create GZIPInputStream? Browsers not have any problem with consuming such responses.

I didn't try this special case but I think the producer side is ok because the response does not have content so Content-Length:0 is ok. But the consumer side is not ok when it try to create GZIPInputStream with nil content.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM