Skip to content

Commit

Permalink
fix(state): stop adding Content-Location header for GET responses
Browse files Browse the repository at this point in the history
Avoids adding a redundant `Content-Location` header in GET responses, which can cause unnecessary complications, such as issues with temporary or preview resources lacking an ID. While this behavior complies with the HTTP specification (RFC 9110), it is unnecessary and potentially problematic.
  • Loading branch information
vinceAmstoutz committed Jan 13, 2025
1 parent ccd2a15 commit 6d74cd2
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions features/main/crud.feature
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ Feature: Create-Retrieve-Update-Delete
Then the response status code should be 200
And the response should be in JSON
And the header "Content-Type" should be equal to "application/ld+json; charset=utf-8"
And the header "Content-Location" should not exist
And the JSON should be equal to:
"""
{
Expand Down
2 changes: 1 addition & 1 deletion src/State/Processor/RespondProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public function process(mixed $data, Operation $operation, array $uriVariables =
$iri = $this->iriConverter->getIriFromResource($operation->getClass(), UrlGeneratorInterface::ABS_PATH, $operation);
}

if ($iri) {
if ($iri && 'GET' !== $method) {
$location = \sprintf('%s.%s', $iri, $request->getRequestFormat());
if (isset($requestParts['query'])) {
$location .= '?'.$requestParts['query'];
Expand Down

0 comments on commit 6d74cd2

Please sign in to comment.