Add a POST body to the request

@param string $body body to add

@return void
@throws CAS_OutOfSequenceException If called after the Request has been sent.
11375
public function setPostBody ($body)
    {
        if ($this->_sent) {
            throw new CAS_OutOfSequenceException(
                'Request has already been sent cannot '.__METHOD__
            );
        }
        if (!$this->isPost) {
            throw new CAS_OutOfSequenceException(
                'Cannot add a POST body to a GET request, use makePost() first.'
            );
        }

        $this->postBody = $body;
    }
41617
protected function setBody($body, $contentType)
    {
        $message = $this->getSwiftMessage();
        $oldBody = $message->getBody();
        $charset = $message->getCharset();
        if (empty($oldBody)) {
            $parts = $message->getChildren();
            $partFound = false;
            foreach ($parts as $key => $part) {
                if (!($part instanceof \Swift_Mime_Attachment)) {
                    /* @var $part \Swift_Mime_MimePart */
                    if ($part->getContentType() == $contentType) {
                        $charset = $part->getCharset();
                        unset($parts[$key]);
                        $partFound = true;
                        break;
                    }
                }
            }
            if ($partFound) {
                reset($parts);
                $message->setChildren($parts);
                $message->addPart($body, $contentType, $charset);
            } else {
                $message->setBody($body, $contentType);
            }
        } else {
            $oldContentType = $message->getContentType();
            if ($oldContentType == $contentType) {
                $message->setBody($body, $contentType);
            } else {
                $message->setBody(null);
                $message->setContentType(null);
                $message->addPart($oldBody, $oldContentType, $charset);
                $message->addPart($body, $contentType, $charset);
            }
        }
    }
567393
public function sendSimpleMessage($to, $body)
    {

        $message = new \sb\XMPP\Message();

        $message->setTo($to);
        $message->setBody($body);
        $this->sendMessage($message);
    }
948894
public static function post($url, $headers = [], $body = null)
    {
        return Request::create('default')->post($url, $headers, $body);
    }
175256
public function buildPostBody($data = null) {
        $reqBody = ($data !== null) ? $data : $this->request_body;


        $this->request_body = (string) $reqBody;
    }
906980
public function setBody($body)
    {
        if(null!==$body && !is_object($body) && !is_string($body) && !is_callable($body) && !is_a($body, \Iterator::class))
        {
            return $this;
        }

        $this->options['body'] = $body;
        return $this;
    }
321807
protected function addPostData(RequestInterface $request, array $body)
    {
        static $fields = ['string' => true, 'array' => true, 'NULL' => true,
            'boolean' => true, 'double' => true, 'integer' => true];

        $post = new PostBody();
        foreach ($body as $key => $value) {
            if (isset($fields[gettype($value)])) {
                $post->setField($key, $value);
            } elseif ($value instanceof PostFileInterface) {
                $post->addFile($value);
            } else {
                $post->addFile(new PostFile($key, $value));
            }
        }

        if ($request->getHeader('Content-Type') == 'multipart/form-data') {
            $post->forceMultipartUpload(true);
        }

        $request->setBody($post);
    }
636270
public function send ()
    {
        if ($this->_sent) {
            throw new CAS_OutOfSequenceException(
                'Request has already been sent cannot send again.'
            );
        }
        if (!count($this->_requests)) {
            throw new CAS_OutOfSequenceException(
                'At least one request must be added via addRequest() before the multi-request can be sent.'
            );
        }

        $this->_sent = true;

        // Initialize our handles and configure all requests.
        $handles = array();
        $multiHandle = curl_multi_init();
        foreach ($this->_requests as $i => $request) {
            $handle = $request->initAndConfigure();
            curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
            $handles[$i] = $handle;
            curl_multi_add_handle($multiHandle, $handle);
        }

        // Execute the requests in parallel.
        do {
            curl_multi_exec($multiHandle, $running);
        } while ($running > 0);

        // Populate all of the responses or errors back into the request objects.
        foreach ($this->_requests as $i => $request) {
            $buf = curl_multi_getcontent($handles[$i]);
            $request->_storeResponseBody($buf);
            curl_multi_remove_handle($multiHandle, $handles[$i]);
            curl_close($handles[$i]);
        }

        curl_multi_close($multiHandle);
    }
754893
protected function addAttachmentBody(array $body)
    {
        foreach ($this->attachments as $attachment) {
            list($name, $data, $mime) = $attachment;
            $mime   = $mime ? $mime : MimeType::getMimeType($name);
            $data   = base64_encode($data);
            $count  = ceil(strlen($data) / 998);
            
            $body[] = '--'.$this->boundary[1];
            $body[] = 'Content-type: '.$mime.'; name="'.$name.'"';
            $body[] = 'Content-disposition: attachment; filename="'.$name.'"';
            $body[] = 'Content-transfer-encoding: base64';
            $body[] = null;
            
            for ($i = 0; $i < $count; $i++) {
                $body[] = substr($data, ($i * 998), 998);
            }
            
            $body[] = null;
            $body[] = null;
        }
        
        $body[] = '--'.$this->boundary[1].'--';
        
        return $body;
    }
682246
public function post($url, $requestBody = null) {
        $posturl = $this->url . $url;
        return $this->restRequest($posturl, 'POST', $requestBody);
    }
1129429
public function insert(Urlshortener_Url $postBody, $optParams = array())
  {
    $params = array('postBody' => $postBody);
    $params = array_merge($params, $optParams);
    return $this->call('insert', array($params), "Urlshortener_Url");
  }
702496
public function post(string $route, $body = [], $headers = [])
    {
        return $this->request('POST', $route, $body, $headers);
    }
1216670
public function put(string $route, $body = [], $headers = [])
    {
        return $this->request('PUT', $route, $body, $headers);
    }
1369854
protected function applyBody(&$contextParams, $methodName, $body, $json = true)
    {
        // request body
        if ($methodName == 'POST' || $methodName == 'PUT') {

            $body = (array)$body;

            if($json){
                $content = @json_encode($body);
                if(!$content){
                    throw new \Exception('Body is not serializable');
                }
            }else{
                $content = http_build_query($body);
            }

            $contextParams['http']['content'] = $content;

            $logger = $this->getLogger();
            $logger->debug('Document body: '.var_export($body, true));
            $logger->debug('Document body (JSON-ified): '.$content);
        }
    }
433504
public function setBody($body)
    {
        if ($body !== false && (empty($body) || !is_array($body) || (count($body) % 2) !== 0)) {
            throw new InvalidResponseException($this->command, $body);
        }
        parent::setBody($body);
    }
1184367
function setBody( $newBody )
    {
        // if it's an object (e.g. ezcMailText) then set it directly, otherwise
        // create a new ezcMailText object to contain the body text
        if ( $newBody instanceof ezcMailPart )
        {
            $this->Mail->body = $newBody;
        }
        else
        {
            $this->Mail->body = new ezcMailText( $newBody, $this->usedCharset() );

            // if the content-type is in the form of 'text/plain'
            if ( strpos( $this->ContentType['type'] ,'/' ) !== false )
            {
                list( $type, $subType ) = explode( '/', $this->ContentType['type'] );
                $this->Mail->body->subType = $subType;
            }
        }
        $newBody = preg_replace( "/\r\n|\r|\n/", eZMail::lineSeparator(), $newBody );
        $this->BodyText = $newBody;
    }
374553
public function setBody($body)
    {
        $body = json_encode($body);

        if ($error = json_last_error()) {
            throw new \ErrorException($error);
        }

        curl_setopt($this->curlHandler, CURLOPT_POSTFIELDS, $body);

        return $this;
    }