mirror of
https://github.com/maximebf/php-debugbar.git
synced 2025-01-17 05:18:32 +01:00
added getDataAsHeaders()
This commit is contained in:
parent
f74037a29d
commit
3c5e8cca50
@ -235,12 +235,13 @@ class DebugBar implements ArrayAccess
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends the data through the HTTP headers
|
||||
* Returns an array of HTTP headers containing the data
|
||||
*
|
||||
* @param string $headerName
|
||||
* @param integer $maxHeaderLength
|
||||
* @return array
|
||||
*/
|
||||
public function sendDataInHeaders($headerName = 'phpdebugbar', $maxHeaderLength = 4096)
|
||||
public function getDataAsHeaders($headerName = 'phpdebugbar', $maxHeaderLength = 4096)
|
||||
{
|
||||
$data = rawurlencode(json_encode(array(
|
||||
'id' => $this->getCurrentRequestId(),
|
||||
@ -260,8 +261,19 @@ class DebugBar implements ArrayAccess
|
||||
$headers[$name] = $chunks[$i];
|
||||
}
|
||||
|
||||
$this->getHttpDriver()->setHeaders($headers);
|
||||
return $headers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends the data through the HTTP headers
|
||||
*
|
||||
* @param string $headerName
|
||||
* @param integer $maxHeaderLength
|
||||
*/
|
||||
public function sendDataInHeaders($headerName = 'phpdebugbar', $maxHeaderLength = 4096)
|
||||
{
|
||||
$headers = $this->getDataAsHeaders($headerName, $maxHeaderLength);
|
||||
$this->getHttpDriver()->setHeaders($headers);
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -54,6 +54,13 @@ class DebugBarTest extends DebugBarTestCase
|
||||
$this->assertEquals($s->data[$this->debugbar->getCurrentRequestId()], $data);
|
||||
}
|
||||
|
||||
public function testGetDataAsHeaders()
|
||||
{
|
||||
$this->debugbar->addCollector($c = new MockCollector(array('foo')));
|
||||
$headers = $this->debugbar->getDataAsHeaders();
|
||||
$this->assertArrayHasKey('phpdebugbar', $headers);
|
||||
}
|
||||
|
||||
public function testSendDataInHeaders()
|
||||
{
|
||||
$http = $this->debugbar->getHttpDriver();
|
||||
|
Loading…
x
Reference in New Issue
Block a user