Exemplo n.º 1
0
 public function encode($encoding)
 {
     if (empty($encoding)) {
         return false;
     }
     $status = Rest_Response_Format::parse_accept($encoding, $matches);
     if (!empty($status)) {
         foreach ($matches as $match) {
             $class = Rest_Response_Encoding::factory($match[1]);
             if (!empty($class)) {
                 // Perform only one type of encoding.
                 $this->_data = $class->encode($this->_data, Arr::get($match, 6, null));
                 return $class;
             }
         }
     }
     throw Rest_Exception::factory(406, 'request_header_accept_encoding_invalid', array(':content_encoding' => $encoding));
 }
Exemplo n.º 2
0
 /**
  * Sends 406 when requesting with an Unrecognized Content-Type
  *
  * @expectedException     HTTP_Exception
  * @expectedExceptionCode 406
  * @group rest.url.default
  */
 function testSends406WhenRequestingResourceWithAnInvalidContentType()
 {
     Rest_Response_Format::factory('text');
 }
Exemplo n.º 3
0
 public function __construct(Request $request, Response $response)
 {
     parent::__construct($request, $response);
     $this->_content_format = Rest_Response_Format::factory($this->request->headers('accept'));
 }