コード例 #1
0
 /**
  * @test
  * @dataProvider mediaTypesWithAndWithoutParameters
  */
 public function trimMediaTypeReturnsJustTheTypeAndSubTypeWithoutParameters($mediaType, $expectedResult)
 {
     $actualResult = MediaTypes::trimMediaType($mediaType);
     $this->assertSame($expectedResult, $actualResult);
 }
コード例 #2
0
ファイル: Request.php プロジェクト: neos/flow
 /**
  * Returns the best fitting IANA media type after applying the content negotiation
  * rules on a possible Accept header.
  *
  * @param array $supportedMediaTypes A list of media types which are supported by the application / controller
  * @param boolean $trim If TRUE, only the type/subtype of the media type is returned. If FALSE, the full original media type string is returned.
  * @return string The media type and sub type which matched, NULL if none matched
  * @api
  */
 public function getNegotiatedMediaType(array $supportedMediaTypes, $trim = true)
 {
     $negotiatedMediaType = null;
     $acceptedMediaTypes = $this->getAcceptedMediaTypes();
     foreach ($acceptedMediaTypes as $acceptedMediaType) {
         foreach ($supportedMediaTypes as $supportedMediaType) {
             if (MediaTypes::mediaRangeMatches($acceptedMediaType, $supportedMediaType)) {
                 $negotiatedMediaType = $supportedMediaType;
                 break 2;
             }
         }
     }
     return $trim ? MediaTypes::trimMediaType($negotiatedMediaType) : $negotiatedMediaType;
 }
コード例 #3
0
 /**
  * Strips off any parameters from the given media type and returns just the type
  * and subtype in the format "type/subtype".
  * @see \Neos\Utility\MediaTypes::trimMediaType()
  *
  * @param string $rawMediaType The full media type, for example "application/json; charset=UTF-8"
  * @return string Just the type and subtype, for example "application/json"
  * @deprecated since Flow 2.1. Use \Neos\Utility\MediaTypes::trimMediaType() instead
  */
 public static function trimMediaType($rawMediaType)
 {
     return MediaTypes::trimMediaType($rawMediaType);
 }