Exemplo n.º 1
0
 private function getBodyToSend()
 {
     if (!empty($this->Serializer) && $this->body !== '') {
         $body = $this->Serializer->serialize($this->body);
         if ($this->Serializer->getContentType()) {
             $this->setHeader('Content-Type', $this->Serializer->getContentType());
         }
         return $body;
     } else {
         $body = $this->body;
         if (!is_scalar($body)) {
             $Serializer = new SerializerJSON();
             $body = $Serializer->serialize($body);
             $this->setHeader('Content-Type', $Serializer->getContentType());
             $this->setHeader('X-Warning', 'Result of request should be serialized to send through. Specify in "ACCEPT" header type of acceptable method of serialization.');
             return $body;
         }
         return $body;
     }
 }