Exemple #1
0
 public function testSetContentType()
 {
     $this->request->setContentType('text/xml');
     $this->assertEquals('text/xml', $this->request->getContentType());
 }
 /**
  * Negotiates the request payload.
  *
  * @param \BedRest\Rest\Request\Request                $restRequest
  * @param \Zend\Http\Request                           $httpRequest
  * @param \Zend\ServiceManager\ServiceLocatorInterface $serviceLocator
  */
 protected function negotiateContent(RestRequest $restRequest, HttpRequest $httpRequest, ServiceLocatorInterface $serviceLocator)
 {
     $content = $httpRequest->getContent();
     $contentType = $httpRequest->getHeader('Content-Type');
     if (!empty($content) && !empty($contentType)) {
         /** @var \BedRest\Content\Negotiation\Negotiator $negotiator */
         $negotiator = $serviceLocator->get('BedRest.ContentNegotiator');
         $restRequest->setContent($negotiator->decode($content, $contentType->value));
         $restRequest->setContentType($contentType);
     }
 }