Moved gzip handling to the top level so that results returned from apis can be compressed too.