Skip to content

Commit

Permalink
Fix created response status code
Browse files Browse the repository at this point in the history
  • Loading branch information
jsor committed Nov 4, 2014
1 parent e0aca57 commit 26caf6f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Response/CreatedResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ class CreatedResponse extends HalResponse
{
public function __construct(Hal $hal, $headers = array(), $prettyPrint = true)
{
parent::__construct($hal, 204, $headers, $prettyPrint);
parent::__construct($hal, 201, $headers, $prettyPrint);

if (!$this->headers->has('Location') && null !== ($url = $hal->getUri())) {
$this->headers->set('Location', $url);
}
}

public static function create($hal = null, $status = 204, $headers = array(), $prettyPrint = true)
public static function create($hal = null, $status = 201, $headers = array(), $prettyPrint = true)
{
return new static($hal, $headers, $prettyPrint);
}
Expand Down
1 change: 1 addition & 0 deletions tests/Response/CreatedResponseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public function it_sets_location_header()
$hal = new Hal('http://example.com');

$response = CreatedResponse::create($hal);
$this->assertSame(201, $response->getStatusCode());
$this->assertSame('http://example.com', $response->headers->get('Location'));
}
}

0 comments on commit 26caf6f

Please sign in to comment.