Skip to content

Commit ba81c01

Browse files
committed
Try to decode content if empty
Trimmed content before inflate failed
1 parent 37fb286 commit ba81c01

2 files changed

Lines changed: 19 additions & 9 deletions

File tree

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file. This projec
44
to [Semantic Versioning] (http://semver.org/). For change log format,
55
use [Keep a Changelog] (http://keepachangelog.com/).
66

7+
## [1.3.1] - 2022-07-19
8+
9+
### Fixed
10+
11+
- Try to decode content if empty
12+
- Trimmed content before inflate failed
13+
714
## [1.3.0] - 2021-11-26
815

916
### Added

src/Client.php

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -342,18 +342,21 @@ public function sendRequest(RequestInterface $request): ResponseInterface
342342
// Body
343343
$stream = new Stream();
344344
$streamData = substr($content, curl_getinfo($ch, CURLINFO_HEADER_SIZE));
345-
if (isset($headers['Content-Encoding'])) {
346-
// Gzip
347-
if (in_array('gzip', $headers['Content-Encoding'])) {
348-
$streamData = gzdecode($streamData);
345+
if (!empty($streamData)) {
346+
if (isset($headers['Content-Encoding'])) {
347+
// Gzip
348+
if (in_array('gzip', $headers['Content-Encoding'])) {
349+
$streamData = gzdecode($streamData);
350+
}
351+
352+
// Deflate
353+
if (in_array('deflate', $headers['Content-Encoding'])) {
354+
$streamData = gzinflate($streamData);
355+
}
349356
}
350357

351-
// Deflate
352-
if (in_array('deflate', $headers['Content-Encoding'])) {
353-
$streamData = gzinflate(trim($streamData));
354-
}
358+
$stream->write($streamData);
355359
}
356-
$stream->write((string)$streamData);
357360

358361
// Construct object
359362
$response = new Response(

0 commit comments

Comments
 (0)