Skip to content

Commit

Permalink
fix: force accept header for plain curl requests
Browse files Browse the repository at this point in the history
  • Loading branch information
g105b committed Jan 31, 2022
1 parent 757c2f3 commit 847f467
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/RouterCallback.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 847f467

Please sign in to comment.