From 1f210db45723b21edd69f39794662b8d64656b93 Mon Sep 17 00:00:00 2001 From: William Durand Date: Fri, 14 Oct 2016 11:17:47 +0200 Subject: [PATCH] Revert "Add `$strict` parameter to `getBest()` to enable exceptions for invalid media types." This reverts commit 56f51ee4af8294d1eae12e186623ee7f2f0d5a2f. --- src/Negotiation/AbstractNegotiator.php | 6 ++---- tests/Negotiation/Tests/NegotiatorTest.php | 11 ----------- 2 files changed, 2 insertions(+), 15 deletions(-) diff --git a/src/Negotiation/AbstractNegotiator.php b/src/Negotiation/AbstractNegotiator.php index 71c53a1..2cd839e 100644 --- a/src/Negotiation/AbstractNegotiator.php +++ b/src/Negotiation/AbstractNegotiator.php @@ -13,7 +13,7 @@ abstract class AbstractNegotiator * * @return AcceptHeader|null best matching type */ - public function getBest($header, array $priorities, $strict = false) + public function getBest($header, array $priorities) { if (empty($priorities)) { throw new InvalidArgument('A set of server priorities should be given.'); @@ -33,9 +33,7 @@ public function getBest($header, array $priorities, $strict = false) try { $acceptedHeaders[] = $this->acceptFactory($h); } catch (Exception\Exception $e) { - if ($strict) { - throw $e; - } + // silently skip in case of invalid headers coming in from a client } } $acceptedPriorities = array(); diff --git a/tests/Negotiation/Tests/NegotiatorTest.php b/tests/Negotiation/Tests/NegotiatorTest.php index a4b4d3c..cb83e60 100644 --- a/tests/Negotiation/Tests/NegotiatorTest.php +++ b/tests/Negotiation/Tests/NegotiatorTest.php @@ -104,17 +104,6 @@ public function testGetBestRespectsQualityOfSource() $this->assertEquals('text/plain', $accept->getType()); } - /** - * @expectedException Negotiation\Exception\InvalidMediaType - */ - public function testGetBestInvalidMediaType() - { - $header = 'sdlfkj20ff; wdf'; - $priorities = array('foo/qwer'); - - $this->negotiator->getBest($header, $priorities, true); - } - /** * @dataProvider dataProviderForTestParseHeader */