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

Already on GitHub? Sign in to your account

Hotfix/restful head identifier #3671

Merged
merged 2 commits into from Feb 5, 2013
Jump to file or symbol
Failed to load files and symbols.
+9 −1
Split
@@ -281,7 +281,7 @@ public function onDispatch(MvcEvent $e)
// HEAD
case 'head':
$id = $this->getIdentifier($routeMatch, $request);
- if ($id !== false) {
+ if ($id === false) {
$id = null;
}
$action = 'head';
@@ -193,6 +193,11 @@ public function testDispatchInvokesHeadMethodWhenNoActionPresentAndHeadInvokedWi
$content = $result->getContent();
$this->assertEquals('', $content);
$this->assertEquals('head', $this->routeMatch->getParam('action'));
+
+ $headers = $this->controller->getResponse()->getHeaders();
+ $this->assertTrue($headers->has('X-ZF2-Id'));
+ $header = $headers->get('X-ZF2-Id');
+ $this->assertEquals(1, $header->getFieldValue());
}
public function testAllowsRegisteringCustomHttpMethodsWithHandlers()
@@ -81,6 +81,9 @@ public function getList()
*/
public function head($id = null)
{
+ if ($id) {
+ $this->getResponse()->getHeaders()->addHeaderLine('X-ZF2-Id', $id);
+ }
}
/**