Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added effective_url support #241

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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,
array('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