Skip to content

Commit

Permalink
fix headerreader
Browse files Browse the repository at this point in the history
  • Loading branch information
timoj committed Jul 23, 2018
1 parent 26b40f2 commit 705295b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/Wuunder/Http/GetRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions src/Wuunder/Http/PostRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 3 additions & 2 deletions src/Wuunder/Http/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ abstract class Request {
protected $url;
protected $apiKey;
protected $result;
protected $headerSize;


public function __construct($url, $apiKey)
Expand Down Expand Up @@ -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
{
Expand Down

0 comments on commit 705295b

Please sign in to comment.