Skip to content

Commit e9c978e

Browse files
committed
fix handling of media range results in the format negotiation (fixes #631)
1 parent d6c72b6 commit e9c978e

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

Util/FormatNegotiator.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Symfony\Component\HttpFoundation\RequestMatcherInterface;
1616

1717
use Negotiation\FormatNegotiator as BaseFormatNegotiator;
18+
use Negotiation\AcceptHeader;
1819

1920
class FormatNegotiator implements MediaTypeNegotiatorInterface
2021
{
@@ -96,7 +97,7 @@ public function getBestMediaType(Request $request)
9697

9798
$mimeTypes = $this->formatNegotiator->normalizePriorities($options['priorities']);
9899
$mediaType = $this->formatNegotiator->getBest($acceptHeader, $mimeTypes);
99-
if (null !== $mediaType) {
100+
if (!$mediaType instanceof AcceptHeader || !$mediaType->isMediaRange()) {
100101
return $mediaType->getValue();
101102
}
102103

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"php": ">=5.3.2",
2626
"symfony/framework-bundle": "~2.2",
2727
"doctrine/inflector": "1.0.*",
28-
"willdurand/negotiation": "~1.1.0"
28+
"willdurand/negotiation": "~1.2.0"
2929
},
3030

3131
"require-dev": {

0 commit comments

Comments
 (0)