From 6b3c1834a60188aefc7ad515aed1416471bfcf79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=B0=D0=BD=D0=B8=D0=B8=D0=BB=20=D0=AD=D0=B9=D0=B7?= =?UTF-8?q?=D0=B5=D1=80=D0=BC=D0=B0=D0=BD?= Date: Tue, 23 Apr 2019 18:50:07 +0300 Subject: [PATCH 1/3] hotfix / parse headers --- src/HttpClients/HttpClientRawResponse.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/HttpClients/HttpClientRawResponse.php b/src/HttpClients/HttpClientRawResponse.php index 09c541d..61b3420 100644 --- a/src/HttpClients/HttpClientRawResponse.php +++ b/src/HttpClients/HttpClientRawResponse.php @@ -76,7 +76,7 @@ private function setHeadersAndCode($rawHeaders) // or a proxy was followed, etc $headerCollection = explode("\n\n", trim($rawHeaders)); // We just want the last response (at the end) - $rawHeader = array_pop($headerCollection); + $rawHeader = array_shift($headerCollection); $headerComponents = explode("\n", (string)$rawHeader); foreach ($headerComponents as $line) { if (strpos($line, ': ') === false) { From 6c9584a197d1148c053c979f397b56882eaf7141 Mon Sep 17 00:00:00 2001 From: QSOFT-DEVOLOPER <47108376+QSOFT-DEVOLOPER@users.noreply.github.com> Date: Wed, 24 Apr 2019 15:27:35 +0300 Subject: [PATCH 2/3] Update HttpClientRawResponse.php --- src/HttpClients/HttpClientRawResponse.php | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/HttpClients/HttpClientRawResponse.php b/src/HttpClients/HttpClientRawResponse.php index 61b3420..c479fb7 100644 --- a/src/HttpClients/HttpClientRawResponse.php +++ b/src/HttpClients/HttpClientRawResponse.php @@ -76,14 +76,16 @@ private function setHeadersAndCode($rawHeaders) // or a proxy was followed, etc $headerCollection = explode("\n\n", trim($rawHeaders)); // We just want the last response (at the end) - $rawHeader = array_shift($headerCollection); - $headerComponents = explode("\n", (string)$rawHeader); - foreach ($headerComponents as $line) { - if (strpos($line, ': ') === false) { - $httpCode = $this->getHttpResponseCodeFromHeader($line); - } else { - list($key, $value) = explode(': ', $line, 2); - $headers[$key] = $value; + while($httpCode === 0 && count($headerCollection) > 0) { + $rawHeader = array_pop($headerCollection); + $headerComponents = explode("\n", (string)$rawHeader); + foreach ($headerComponents as $line) { + if (strpos($line, ': ') === false) { + $httpCode = $this->getHttpResponseCodeFromHeader($line); + } else { + list($key, $value) = explode(': ', $line, 2); + $headers[$key] = $value; + } } } From 049d14363e017d2cdbf5041c6cd565774cb1f2c5 Mon Sep 17 00:00:00 2001 From: QSOFT-DEVOLOPER <47108376+QSOFT-DEVOLOPER@users.noreply.github.com> Date: Wed, 24 Apr 2019 15:33:35 +0300 Subject: [PATCH 3/3] fix / codestyle --- src/HttpClients/HttpClientRawResponse.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/HttpClients/HttpClientRawResponse.php b/src/HttpClients/HttpClientRawResponse.php index c479fb7..7c3082d 100644 --- a/src/HttpClients/HttpClientRawResponse.php +++ b/src/HttpClients/HttpClientRawResponse.php @@ -76,7 +76,7 @@ private function setHeadersAndCode($rawHeaders) // or a proxy was followed, etc $headerCollection = explode("\n\n", trim($rawHeaders)); // We just want the last response (at the end) - while($httpCode === 0 && count($headerCollection) > 0) { + while ($httpCode === 0 && count($headerCollection) > 0) { $rawHeader = array_pop($headerCollection); $headerComponents = explode("\n", (string)$rawHeader); foreach ($headerComponents as $line) {