Build RAW post body

@param string $data
175256
public function buildPostBody($data = null) {
        $reqBody = ($data !== null) ? $data : $this->request_body;


        $this->request_body = (string) $reqBody;
    }
1298690
public function sendData($data)
    {
        $httpResponse = $this->httpClient->post($data['url'], null, $data['params'])->send();

        // The body is a string.
        $body = $httpResponse->getBody();

        // Split into lines.
        $data = json_decode($body);

        return $this->response = new OAuthConfirmResponse($this, $data);
    }
760588
protected function set_post_data( $data, $post ) {
		$data['post_title'] = $post->post_title;
		$data['post']       = $post;
		if ( $this->user_can( 'read_post' ) ) {
			$data['edit_link'] = get_edit_post_link( $post->ID );
		}

		foreach ( $this->get_data_field_settings() as $k => $v ) {
			$data[ $k ] = $this->sanitize_input( $this->app->utility->array_get( $data, $k ), $v['type'] );
		}

		return $data;
	}
38564
protected function setBody($data)
    {
        $this->responseWriter->setBody($this->response, $data, $this->request);
    }
192592
public function setResponseBody($data)
    {
        if (!is_string($data)) {
            $data = json_encode($data, \JSON_PRETTY_PRINT);
        }
        $this->response->getBody()->write($data);
        return $this;
    }
616773
public function write($data = null) {
		if (!is_resource($this->_resource)) {
			return false;
		}
		if (!is_object($data)) {
			$data = $this->_instance($this->_classes['request'], (array) $data + $this->_config);
		}
		$this->set(CURLOPT_URL, $data->to('url'));

		if ($data instanceof Message) {
			if (!empty($this->_config['ignoreExpect'])) {
				$data->headers('Expect', ' ');
			}
			if (isset($data->headers)) {
				$this->set(CURLOPT_HTTPHEADER, $data->headers());
			}
			if (isset($data->method) && $data->method === 'POST') {
				$this->set([CURLOPT_POST => true, CURLOPT_POSTFIELDS => $data->body()]);
			}
			if (isset($data->method) && in_array($data->method,['PUT','PATCH','DELETE'])) {
				$this->set([
					CURLOPT_CUSTOMREQUEST => $data->method,
					CURLOPT_POSTFIELDS => $data->body()
				]);
			}
		}
		return (boolean) curl_setopt_array($this->_resource, $this->options);
	}
167566
private function setData($data)
	{
		// Não exibir somente strings
		if (is_string($data)) {
			$data = [$data];
		}
		// Setar o JSON
		$body = $this->getBody();
		$body->rewind();
		$json = json_encode($data);
		if (config('system.debug', false)) {
			$json = jsonpp( str_replace(['\n','\\\\','\t'],["\n",'\\',"\t"], $json ) );
		}
		$body->write($json);
		// Ensure that the json encoding passed successfully
		if ($json === false) {
			throw new \RuntimeException(json_last_error_msg(), json_last_error());
		}
	}
1125018
public function post($data)
    {
        $args = func_get_args();
        if(count($args) == 1) {
            $args = null;
        } else {
            $data = array_pop($args);
        }

        $response = '';

        try {
            $response = $this->client->request($this, 'post', $args, $data);
            return $response['data'];
        } catch (Exception $ex) {
            $this->dispatchException($ex);
        }

    }
1302892
public function setRawJsonBody(array $data)
    {
        $this->addHeader('Content-Type', 'application/json');
        $this->setBody(Stream::factory(json_encode($data)));
        return $this;
    }
684446
public function data($data)
    {
        if ($this->_rcpt == false) {
            throw new SMTPException(__('Must call RCPT before calling DATA'));
        }

        $this->_send('DATA');
        $this->_expect(354, 120);

        foreach ($this->_header_fields as $name => $body) {
            // Every header can contain an array. Will insert multiple header fields of that type with the contents of array.
            // Useful for multiple recipients, for instance.
            if (!is_array($body)) {
                $body = array($body);
            }

            foreach ($body as $val) {
                $this->_send($name . ': ' . $val);
            }
        }
        // Send an empty newline. Solves bugs with Apple Mail
        $this->_send('');

        // Because the message can contain \n as a newline, replace all \r\n with \n and explode on \n.
        // The send() function will use the proper line ending (\r\n).
        $data = str_replace("\r\n", "\n", $data);
        $data_arr = explode("\n", $data);

        foreach ($data_arr as $line) {
            // Escape line if first character is a period (dot). http://tools.ietf.org/html/rfc2821#section-4.5.2
            if (strpos($line, '.') === 0) {
                $line = '.' . $line;
            }
            $this->_send($line);
        }

        $this->_send('.');
        $this->_expect(250, 600);
        $this->_data = true;
    }
648376
public function setPayload($data)
    {
        if (!is_string($data)) {
            if (is_array($data)) {
                $data = json_encode($data, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
            } else {
                $data = serialize($data);
            }
        }

        $maxLength = 255;
        if (mb_strlen($data) > $maxLength) {
            // Truncate too long payload
            $data = mb_substr($data, 0, $maxLength - 3) . '...';
        }

        $this->payload = $data ? $data : null;

        return $this;
    }
1253551
protected function buildBody($attachments = array())
    {
        $this->debug->groupCollapsed(__METHOD__);
        #$this->debug->log('attachments',$attachments);
        $body = '';
        $eol = "\r\n";
        $mimeBoundary = '==Multipart_Boundary_x'.substr(md5(uniqid(rand(), true)), 0, 10).'x';
        $multipartType = '';
            // 'multipart/mixed';
            // 'multipart/alternative';
            // 'multipart/related';
        $contentTypes = array();
        $isSelfCalled = Php::getCallerInfo(false) == __CLASS__.'::'.__FUNCTION__;
        $this->debug->log('isSelfCalled', $isSelfCalled);
        for ($k=0; $k<count($attachments); $k++) {
            $a = $attachments[$k];
            $keys = array_keys($a);
            if ($k==0 && is_string($a)) {
                $multipartType = $a;
                continue;
            } elseif ($keys[0] == '0') {
                $this->debug->log('new array');
                list($type, $content) = $this->buildBody($a);
                $body .= '--'.$mimeBoundary.$eol;
                $body .= 'Content-Type: '.$type.$eol.$eol;
                $body .= $content;
                continue;
            }
            $a = getAttachmentArray($a);
            // .'Content-Type: text/plain; charset="ISO-8859-1"'.$eol
            // .'Content-Transfer-Encoding: 7bit'.$eol
            if (empty($multipartType)) {
                if ($a['content_type'] == 'text/html') {
                    $this->debug->log('html');
                    $multipartType = 'multipart/alternative';
                    if (strpos($a['body'], 'cid:')) {
                        $this->debug->log('found "cid:"');
                        if (in_array('text/plain', $contentTypes)) {
                            $this->debug->log('prior alternative');
                            $attachments[$k] = $a;
                            $attachments[] = array_splice($attachments, $k);
                            $k--;
                            continue;
                        } else {
                            $multipartType = 'multipart/related';
                        }
                    }
                }
            }
            if (!in_array($a['content_type'], $contentTypes)) {
                $contentTypes[] = $a['content_type'];
            }
            $body .= '--'.$mimeBoundary.$eol;
            $body .= 'Content-Type: '.$a['content_type'].';'.( !empty($a['filename']) ? ' name="'.$a['filename'].'";' : '' ).$eol;  // charset="ISO-8859-1";
            if (!empty($a['filename'])) {
                $body .= 'Content-Disposition: '.$a['disposition'].'; filename="'.$a['filename'].'"'.$eol;
            }
            if (!empty($a['content_id'])) {
                $body .= 'Content-ID: <'.$a['content_id'].'>'.$eol;
            }
            if (!empty($a['content_transfer_encoding'])) {
                $body .= 'Content-Transfer-Encoding: '.$a['content_transfer_encoding'].$eol;
            }
            $body .= $eol;
            $body .= $a['body'].$eol.$eol;
        }
        $body .= '--'.$mimeBoundary.'--'.$eol;
        #$this->debug->log('contentTypes', $contentTypes);
        if (!$isSelfCalled) {
            $body = ''
                .'This is a multi-part message in MIME format.'.$eol
                .$eol
                .$body;
        }
        if (empty($multipartType)) {
            $multipartType = 'multipart/mixed';
        }
        $multipartType = $multipartType.'; boundary="'.$mimeBoundary.'";';
        $this->debug->groupEnd();
        return array($multipartType, $body);
    }
222462
public function sendData($data)
    {
        $httpResponse = $this->sendRequest($data);

        $responseClass = $this->getResponseClassName();
        return $this->response = new $responseClass($this, $httpResponse);
    }
1159353
public function setData($data)
    {
        $body = new Doozr_Response_Body();
        $body->write($data);

        $this->setBody($body);
    }
397455
public function setRawBody($rawBody)
    {
        $body = new MemoryStream();
        $body->write($rawBody);
        $this->setBody($body);
    }
934087
public function put ($data)
		{
			$this->_options[ CURLOPT_CUSTOMREQUEST ] = 'PUT';
			$this->_options[ CURLOPT_POSTFIELDS ] = http_build_query($data);

			return $this->send();
		}
516904
protected function _post($data) {
		$ch = curl_init();
		curl_setopt_array($ch, array(
			CURLOPT_URL            => static::ENDPOINT,
			CURLOPT_POST           => true,
			CURLOPT_POSTFIELDS     => json_encode($data),
			CURLOPT_HEADER         => false,
			CURLOPT_RETURNTRANSFER => true,
			CURLOPT_SSL_VERIFYPEER => true,
			CURLOPT_SSL_VERIFYHOST => 2,
			CURLOPT_FOLLOWLOCATION => false,
			CURLOPT_HTTPHEADER => array('Content-Type: application/json')
		));

		$response = curl_exec($ch);
		curl_close($ch);

		if ($response === false) {
			throw new Exception('Failed to contact BrowserID verification service');
		}

		$decodedResponse = json_decode($response);
		if (!$decodedResponse) {
			throw new Exception('Response is not valid JSON');
		}

		return $decodedResponse;
	}