Skip to content

Commit

Permalink
added effective_url support
Browse files Browse the repository at this point in the history
  • Loading branch information
hthabet committed Feb 1, 2018
1 parent a45aa4c commit 439a96d
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions src/VCR/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ class Response
protected $curlInfo = array();

protected $httpVersion;
/**
* @var string
*/
protected $effectiveUrl;

/**
* @param string|array $status
Expand All @@ -44,6 +48,7 @@ public function __construct($status, array $headers = array(), $body = null, arr
$this->headers = $headers;
$this->body = $body;
$this->curlInfo = $curlInfo;
$this->effectiveUrl = isset($curlInfo['url']) ? $curlInfo['url'] : '';
}

/**
Expand All @@ -63,9 +68,10 @@ public function toArray()

return array_filter(
array(
'status' => $this->status,
'headers' => $this->getHeaders(),
'body' => $body
'status' => $this->status,
'headers' => $this->getHeaders(),
'body' => $body,
'effective_url' => $this->getEffectiveUrl()
)
);
}
Expand Down Expand Up @@ -94,7 +100,8 @@ public static function fromArray(array $response)
return new static(
isset($response['status']) ? $response['status'] : 200,
isset($response['headers']) ? $response['headers'] : array(),
$body
$body,
['url' => isset($response['url']) ? $response['url'] : '']
);
}

Expand Down Expand Up @@ -168,6 +175,14 @@ public function getStatusMessage()
return $this->status['message'];
}

/**
* @return string
*/
public function getEffectiveUrl()
{
return $this->effectiveUrl;
}

/**
* @param string|array $status
*/
Expand Down

0 comments on commit 439a96d

Please sign in to comment.