Skip to content

Commit

Permalink
Merge branch 'weierophinney-hotfix/restful-head-identifier' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
ezimuel committed Feb 5, 2013
2 parents 557edbf + 539781b commit 5e94635
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion library/Zend/Mvc/Controller/AbstractRestfulController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
5 changes: 5 additions & 0 deletions tests/ZendTest/Mvc/Controller/RestfulControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ public function getList()
*/
public function head($id = null)
{
if ($id) {
$this->getResponse()->getHeaders()->addHeaderLine('X-ZF2-Id', $id);
}
}

/**
Expand Down

0 comments on commit 5e94635

Please sign in to comment.