Skip to content

Commit

Permalink
fix!(state): precise format on content-location
Browse files Browse the repository at this point in the history
  • Loading branch information
soyuka committed Sep 19, 2024
1 parent 4a22716 commit f8c0c6a
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/State/Processor/RespondProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public function process(mixed $data, Operation $operation, array $uriVariables =
&& ($isAlternateResourceMetadata || $canonicalUriTemplate)
) {
$canonicalOperation = $operation;
if ($this->operationMetadataFactory && null !== ($canonicalUriTemplate)) {
if ($this->operationMetadataFactory && null !== $canonicalUriTemplate) {
$canonicalOperation = $this->operationMetadataFactory->create($canonicalUriTemplate, $context);
}

Expand All @@ -127,10 +127,12 @@ public function process(mixed $data, Operation $operation, array $uriVariables =
$iri = $this->iriConverter->getIriFromResource($operation->getClass(), UrlGeneratorInterface::ABS_PATH, $operation);
}

$headers['Content-Location'] = sprintf('%s.%s', $iri, $request->getRequestFormat());
if ($iri) {
$headers['Content-Location'] = \sprintf('%s.%s', $iri, $request->getRequestFormat());

if ((201 === $status || (300 <= $status && $status < 400)) && 'POST' === $method && !isset($headers['Location'])) {
$headers['Location'] = $iri;
if ((201 === $status || (300 <= $status && $status < 400)) && 'POST' === $method && !isset($headers['Location'])) {
$headers['Location'] = $iri;
}
}
} catch (InvalidArgumentException|ItemNotFoundException|RuntimeException) {
}
Expand Down

0 comments on commit f8c0c6a

Please sign in to comment.