From 847f46706a358340989cb996ce499fdcd8fca498 Mon Sep 17 00:00:00 2001 From: Greg Bowler Date: Mon, 31 Jan 2022 13:46:54 +0000 Subject: [PATCH] fix: force accept header for plain curl requests --- src/RouterCallback.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/RouterCallback.php b/src/RouterCallback.php index b78c7c0..e62acc3 100644 --- a/src/RouterCallback.php +++ b/src/RouterCallback.php @@ -76,6 +76,10 @@ public function matchesPath(string $requestPath):bool { } public function matchesAccept(string $acceptHeader):bool { + if(!$acceptHeader) { + $acceptHeader = "*/*"; + } + $acceptArgument = $this->attribute->getArguments()["accept"] ?? null; if(is_null($acceptArgument)) { return true; @@ -112,6 +116,9 @@ public function getAcceptedTypes(string $acceptHeader = ""):array { } public function getBestNegotiation(string $acceptHeader):?Accept { + if(!$acceptHeader) { + $acceptHeader = "*/*"; + } /** @var Accept $mediaType */ /** @noinspection PhpUnnecessaryLocalVariableInspection */ $mediaType = $this->negotiator->getBest(