39 return array(
'request.complete' => array(
'onRequestComplete', 255));
48 $response = $event[
'response'];
50 if (!$contentMd5 = $response->getContentMd5()) {
54 $contentEncoding = $response->getContentEncoding();
55 if ($contentEncoding && !$this->contentEncoded) {
60 if ($this->contentLengthCutoff) {
61 $size = $response->getContentLength() ?: $response->getBody()->getSize();
62 if (!$size || $size > $this->contentLengthCutoff) {
67 if (!$contentEncoding) {
68 $hash = $response->getBody()->getContentMd5();
69 } elseif ($contentEncoding ==
'gzip') {
70 $response->getBody()->compress(
'zlib.deflate');
71 $hash = $response->getBody()->getContentMd5();
72 $response->getBody()->uncompress();
73 } elseif ($contentEncoding ==
'compress') {
74 $response->getBody()->compress(
'bzip2.compress');
75 $hash = $response->getBody()->getContentMd5();
76 $response->getBody()->uncompress();
81 if ($contentMd5 !== $hash) {
82 throw new UnexpectedValueException(
83 "The response entity body may have been modified over the wire. The Content-MD5 "
84 .
"received ({$contentMd5}) did not match the calculated MD5 hash ({$hash})."