From 705295b23b4f3ae4563814ce2a7f2b5af7a6f760 Mon Sep 17 00:00:00 2001 From: Timo Janssrn Date: Mon, 23 Jul 2018 15:12:41 +0200 Subject: [PATCH] fix headerreader --- src/Wuunder/Http/GetRequest.php | 1 + src/Wuunder/Http/PostRequest.php | 1 + src/Wuunder/Http/Request.php | 5 +++-- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Wuunder/Http/GetRequest.php b/src/Wuunder/Http/GetRequest.php index 9cd93fa..bb213a3 100644 --- a/src/Wuunder/Http/GetRequest.php +++ b/src/Wuunder/Http/GetRequest.php @@ -33,6 +33,7 @@ public function send() // Execute the cURL, fetch the XML $result = curl_exec($cc); $this->result = $result; + $this->headerSize = curl_getinfo($cc, CURLINFO_HEADER_SIZE); // Close connection curl_close($cc); diff --git a/src/Wuunder/Http/PostRequest.php b/src/Wuunder/Http/PostRequest.php index d1fd9a6..36f71a8 100644 --- a/src/Wuunder/Http/PostRequest.php +++ b/src/Wuunder/Http/PostRequest.php @@ -37,6 +37,7 @@ public function send() // Execute the cURL, fetch the XML $result = curl_exec($cc); $this->result = $result; + $this->headerSize = curl_getinfo($cc, CURLINFO_HEADER_SIZE); // Close connection curl_close($cc); diff --git a/src/Wuunder/Http/Request.php b/src/Wuunder/Http/Request.php index 0066ba6..13e7657 100644 --- a/src/Wuunder/Http/Request.php +++ b/src/Wuunder/Http/Request.php @@ -7,6 +7,7 @@ abstract class Request { protected $url; protected $apiKey; protected $result; + protected $headerSize; public function __construct($url, $apiKey) @@ -44,10 +45,10 @@ public function getResponseHeaders() { $headers = array(); - $header_text = substr($this->result, 0, strrpos($this->result, "\r\n\r\n")); + $header_text = substr($this->result, 0, $this->headerSize); foreach (explode("\r\n", $header_text) as $i => $line) - if (count($line) > 5 && substr($line, 0, 5) === "HTTPV") + if (count($line) > 4 && substr($line, 0, 4) === "HTTP") $headers['http_code'] = $line; else {