mutatron
mutatron

Reputation: 563

zf2 decodeGzip, why is it protected?

I'm getting back what appears to be gzipped data in a call to a zf2 api. The content-type is gzip, and the content body looks encoded. So I tried this:

    $decoded = $response->decodeGzip($response->getContent());

and I got back this error:

Call to protected method Zend\Http\Response::decodeGzip()

Why is it protected? It seems like decoding gzipped data would be a handy thing to be able to do.

Upvotes: 1

Views: 566

Answers (1)

Jurian Sluiman
Jurian Sluiman

Reputation: 13558

You should use $response->getBody(). The getBody() method checks the Content-Encoding header and if this is gzip, it will extract the body from the Gzipped content.

You can check this method in the online repository: Zend\Http\Response

Upvotes: 6

Related Questions