mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
API Adding setURL to HTTPRequest object
The current RootURLController needs to be able to change the url of a request, so I've added it.
This commit is contained in:
parent
3457f43839
commit
9258485aeb
@ -104,6 +104,24 @@ class SS_HTTPRequest implements ArrayAccess {
|
||||
*/
|
||||
public function __construct($httpMethod, $url, $getVars = array(), $postVars = array(), $body = null) {
|
||||
$this->httpMethod = strtoupper(self::detect_method($httpMethod, $postVars));
|
||||
$this->setUrl($url);
|
||||
|
||||
$this->getVars = (array)$getVars;
|
||||
$this->postVars = (array)$postVars;
|
||||
$this->body = $body;
|
||||
}
|
||||
|
||||
/**
|
||||
* Allow the setting of a URL
|
||||
*
|
||||
* This is here so that RootURLController can change the URL of the request
|
||||
* without us loosing all the other info attached (like headers)
|
||||
*
|
||||
* @param string The new URL
|
||||
*
|
||||
* @return SS_HTTPRequest The updated request
|
||||
*/
|
||||
public function setUrl($url) {
|
||||
$this->url = $url;
|
||||
|
||||
// Normalize URL if its relative (strictly speaking), or has leading slashes
|
||||
@ -117,9 +135,7 @@ class SS_HTTPRequest implements ArrayAccess {
|
||||
if($this->url) $this->dirParts = preg_split('|/+|', $this->url);
|
||||
else $this->dirParts = array();
|
||||
|
||||
$this->getVars = (array)$getVars;
|
||||
$this->postVars = (array)$postVars;
|
||||
$this->body = $body;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -610,7 +626,7 @@ class SS_HTTPRequest implements ArrayAccess {
|
||||
for($i=0;$i<$count;$i++) {
|
||||
$value = array_shift($this->dirParts);
|
||||
|
||||
if(!$value) break;
|
||||
if($value === null) break;
|
||||
|
||||
$return[] = $value;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user