Decompress gzipped http response inside Vim

For debugging purposes I sniffed some requests & responses from my server/client. The compression is enabled so the responses are sent in gzip format. I know that probably I could just disable mod_deflate, but… out of curiosity, is there a way to decompress the gzipped response right in vim?

Here’s an example of a response:

I’d like to select the gzipped text section & decompress it on the fly (maybe running a terminal command on it? something like :!sort to sort lines…)

Select the gzipped text section (or provide a range, e.g. :/^$\n\zs/,$). Then you can unzip the part by piping it through the external gunzip command (which naturally must be installed & accessible):

When I tested this, the buffer had to be opened in 'binary' mode: :edit ++bin filename. Also, I received gzip: stdin: unexpected end of file after the unpacked contents, yet that probably can be tolerated.