Skip to content

Commit

Permalink
bugfix request class
Browse files Browse the repository at this point in the history
  • Loading branch information
timoj committed Jul 30, 2018
1 parent 24197be commit 2a13396
Showing 1 changed file with 21 additions and 20 deletions.
41 changes: 21 additions & 20 deletions src/Wuunder/Http/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

namespace Wuunder\Http;

abstract class Request {
abstract class Request
{

protected $url;
protected $apiKey;
Expand All @@ -19,41 +20,41 @@ public function __construct($url, $apiKey)
abstract protected function send();

/**
* Returns the whole response from a response
*
* @return $result
*/
public function getResponse() {
* Returns the whole response from a response
*
* @return $result
*/
public function getResponse()
{
return $this->result;
}

/**
* Returns the response body from a response
*
* @return $result (body)
*/
public function getBody() {
* Returns the response body from a response
*
* @return $result (body)
*/
public function getBody()
{
return substr($this->result, $this->headerSize);
}

/**
* Returns the headers from a response
*
* @return $headers
*/
* Returns the headers from a response
*
* @return $headers
*/
public function getResponseHeaders()
{
$headers = array();

$header_text = substr($this->result, 0, $this->headerSize);

foreach (explode("\r\n", $header_text) as $i => $line)
if (strlen($line) > 4 && substr($line, 0, 4) === "HTTP")
if (strlen($line) > 4 && substr($line, 0, 4) === "HTTP") {
$headers['http_code'] = $line;
else
{
list ($key, $value) = explode(': ', $line);

} else {
list ($key, $value) = array_pad(explode(': ', $line, 2), 2, null);
$headers[$key] = $value;
}

Expand Down

0 comments on commit 2a13396

Please sign in to comment.