protected function serveBody(ResponseInterface $response, $compression = null)
    {
        $body = $response->getBody();
        $body->rewind();
        $out = fopen('php://output', 'wb');
        if ($compression == 'bzip2') {
            fwrite($out, bzcompress($body->getContents()));
        } elseif ($compression == 'gzip') {
            fwrite($out, gzencode($body->getContents()));
        } else {
            while (! $body->eof()) {
                fwrite($out, $body->read(8192));
            }
        }
        fclose($out);
        $body->close();
    }