Пример #1
0
 public static function deriveFromRequest(Request $request)
 {
     //build an empty header
     $headers = new Headers();
     //analyze each possible acceptable encoding
     foreach ($request->getHeader('Accept') as $acceptable) {
         if (in_array($acceptable, ['text/yaml', 'text/x-yaml', 'application/yaml', 'application/x-yaml', 'application/xml', 'text/xml', 'application/json'])) {
             //select (and store) the content type
             $headers->set('Content-Type', $acceptable);
             //the content-type has been selected
             break;
         }
     }
     //build and return the response
     return new self(200, $headers);
 }