TS-2270 ESI Plugin can have infinite loop on gunzip

Reviewed: leif

Note: I'm not an expert on gzip, but these changes seems
inline with how we deal with this in the gzip plugin.