Skip to content

Commit 49ea482

Browse files
committed
Headers "Allow" and "Accept-Post" are not added if we return an error to avoid sending incorrect values.
1 parent 2f5e432 commit 49ea482

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/State/Processor/RespondProcessor.php

+7-5
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,14 @@ public function process(mixed $data, Operation $operation, array $uriVariables =
9393
$headers['Accept-Patch'] = $acceptPatch;
9494
}
9595

96-
$allowedMethods = $this->getAllowedMethods($context['resource_class'] ?? null, $operation->getUriTemplate());
97-
$headers['Allow'] = implode(', ', $allowedMethods);
96+
if (!$exception) {
97+
$allowedMethods = $this->getAllowedMethods($context['resource_class'] ?? null, $operation->getUriTemplate());
98+
$headers['Allow'] = implode(', ', $allowedMethods);
9899

99-
$outputFormats = $operation->getOutputFormats();
100-
if (\is_array($outputFormats) && [] !== $outputFormats && \in_array('POST', $allowedMethods, true)) {
101-
$headers['Accept-Post'] = implode(', ', array_merge(...array_values($outputFormats)));
100+
$outputFormats = $operation->getOutputFormats();
101+
if (\is_array($outputFormats) && [] !== $outputFormats && \in_array('POST', $allowedMethods, true)) {
102+
$headers['Accept-Post'] = implode(', ', array_merge(...array_values($outputFormats)));
103+
}
102104
}
103105

104106
$method = $request->getMethod();

0 commit comments

Comments
 (0)