Skip to content
This repository has been archived by the owner on Jun 30, 2020. It is now read-only.

Commit

Permalink
silenced exception throwed by FormaNegotiator
Browse files Browse the repository at this point in the history
  • Loading branch information
oscarotero committed Nov 5, 2015
1 parent 3e1ab60 commit d572c7f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/Middleware/FormatNegotiator.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,12 @@ protected function getFromHeader(ServerRequestInterface $request)
}

$priorities = call_user_func_array('array_merge', array_values($this->formats));
$accept = (new Negotiator())->getBest($accept, $priorities);

try {
$accept = (new Negotiator())->getBest($accept, $priorities);
} catch (\Exception $exception) {
return;
}

if ($accept) {
$accept = $accept->getValue();
Expand Down
4 changes: 4 additions & 0 deletions tests/FormatNegotiatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ public function formatsProvider()
'/',
'application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5',
'html',
],[
'/',
'text/html, image/gif, image/jpeg, *; q=0.2, */*; q=0.2',
'html',
],
];
}
Expand Down

0 comments on commit d572c7f

Please sign in to comment.