diff --git a/src/DebugBar/DebugBar.php b/src/DebugBar/DebugBar.php index db08c05..bdd886f 100644 --- a/src/DebugBar/DebugBar.php +++ b/src/DebugBar/DebugBar.php @@ -233,14 +233,15 @@ class DebugBar implements ArrayAccess } return $this->data; } - + /** - * 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]; } + 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; } diff --git a/tests/DebugBar/Tests/DebugBarTest.php b/tests/DebugBar/Tests/DebugBarTest.php index c6bd2cc..f01808e 100644 --- a/tests/DebugBar/Tests/DebugBarTest.php +++ b/tests/DebugBar/Tests/DebugBarTest.php @@ -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();