mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 09:06:17 +00:00
commit
204fb4b864
2 changed files with 28 additions and 0 deletions
|
@ -584,6 +584,22 @@ class CakeResponse {
|
||||||
return $this->_headers;
|
return $this->_headers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Acccessor for the location header.
|
||||||
|
*
|
||||||
|
* Get/Set the Location header value.
|
||||||
|
* @param null|string $url Either null to get the current location, or a string to set one.
|
||||||
|
* @return string|null When setting the location null will be returned. When reading the location
|
||||||
|
* a string of the current location header value (if any) will be returned.
|
||||||
|
*/
|
||||||
|
public function location($url = null) {
|
||||||
|
if ($url === null) {
|
||||||
|
$headers = $this->header();
|
||||||
|
return isset($headers['Location']) ? $headers['Location'] : null;
|
||||||
|
}
|
||||||
|
$this->header('Location', $url);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Buffers the response message to be sent
|
* Buffers the response message to be sent
|
||||||
* if $content is null the current buffer is returned
|
* if $content is null the current buffer is returned
|
||||||
|
|
|
@ -1481,4 +1481,16 @@ class CakeResponseTest extends CakeTestCase {
|
||||||
$result = $response->send();
|
$result = $response->send();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test the location method.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testLocation() {
|
||||||
|
$response = new CakeResponse();
|
||||||
|
$this->assertNull($response->location(), 'No header should be set.');
|
||||||
|
$this->assertNull($response->location('http://example.org'), 'Setting a location should return null');
|
||||||
|
$this->assertEquals('http://example.org', $response->location(), 'Reading a location should return the value.');
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue