Skip to content

Commit 847f467

Browse files
author
Greg Bowler
committed
fix: force accept header for plain curl requests
1 parent 757c2f3 commit 847f467

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/RouterCallback.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,10 @@ public function matchesPath(string $requestPath):bool {
7676
}
7777

7878
public function matchesAccept(string $acceptHeader):bool {
79+
if(!$acceptHeader) {
80+
$acceptHeader = "*/*";
81+
}
82+
7983
$acceptArgument = $this->attribute->getArguments()["accept"] ?? null;
8084
if(is_null($acceptArgument)) {
8185
return true;
@@ -112,6 +116,9 @@ public function getAcceptedTypes(string $acceptHeader = ""):array {
112116
}
113117

114118
public function getBestNegotiation(string $acceptHeader):?Accept {
119+
if(!$acceptHeader) {
120+
$acceptHeader = "*/*";
121+
}
115122
/** @var Accept $mediaType */
116123
/** @noinspection PhpUnnecessaryLocalVariableInspection */
117124
$mediaType = $this->negotiator->getBest(

0 commit comments

Comments
 (0)