Prepare parsed body

@return mixed|\SimpleXMLElement
768706
protected function prepareParsedBody()
    {
        if ($this->method == self::METHOD_POST &&
            in_array($this->getMediaType(), ['application/x-www-form-urlencoded', 'multipart/form-data'])
        ) {
            return $_POST;
        } else {
            $body = (string)$this->getBody();

            switch ($this->getMediaType()) {
                case 'application/json':
                    return json_decode($body, true);

                case 'application/xml':
                    return simplexml_load_string($body);

                default:
                    parse_str($body, $output);

                    return $output;
            }
        }
    }
764217
protected function parseDataFromResponse()
    {
        $content = $this->rawResponse->body;
        if (empty($content)) {
            throw new OssException("body is null");
        }
        $xml = simplexml_load_string($content);
        return $xml;
    }
570872
public function getBody()
    {
        if ($this->stream === null) {
            ob_start();
            $this->htmlElement->toHtml();
            $content = ob_get_clean();
            $this->stream = new Stream('php://memory', 'wb+');
            $this->stream->write($content);
        }

        return $this->stream;
    }
197025
private function interpretResponseXML()
    {
        $this->debug_echo("\n\nResponse (xml):\n".$this->state['response']['body_raw']);

        $this->state['response']['body'] = $this->state['response']['body_raw'];

        if ($this->state['response']['code'] < 200 ||
            $this->state['response']['code'] >= 300
        ) {
            $this->handleHttpError();
        }

        return $this->state;
    }
317930
protected function _prepareBody()
    {
        if($this->_streamingRequest) {
            $this->setHeaders(self::CONTENT_LENGTH,
                $this->raw_post_data->getTotalSize());
            return $this->raw_post_data;
        }
        else {
            return parent::_prepareBody();
        }
    }
659253
protected function parseDataFromResponse()
    {
        $content = $this->rawResponse->body;
        $config = new RefererConfig();
        $config->parseFromXml($content);
        return $config;
    }
1161737
protected function parse($body)
    {
        $disableEntities = libxml_disable_entity_loader(true);
        $internalErrors = libxml_use_internal_errors(true);

        try {
            $xml = new SimpleXMLElement((string) $body ?: '<root />', LIBXML_NONET);

            return json_decode(json_encode($xml), true);
        } catch (Exception $e) {
            //
        } catch (Throwable $e) {
            //
        } finally {
            libxml_disable_entity_loader($disableEntities);
            libxml_use_internal_errors($internalErrors);
        }
    }
1102043
public function generatePlainPartFromBody()
    {
        $plainPart = $this->findPlainPart();
        if ($plainPart) {
            $this->getSwiftMessage()->detach($plainPart);
        }
        unset($plainPart);

        $this->getSwiftMessage()->addPart(
            Convert::xml2raw($this->getBody()),
            'text/plain',
            'utf-8'
        );

        return $this;
    }
292946
protected function parseDataFromResponse()
    {
        $content = $this->rawResponse->body;
        $xml = simplexml_load_string($content);
        if (isset($xml->UploadId)) {
            return strval($xml->UploadId);
        }
        throw new OssException("cannot get UploadId");
    }
1029382
protected function _prepareBody()
    {
        // According to RFC2616, a TRACE request should not have a body.
        if ($this->method == self::TRACE) {
            return '';
        }

        // If we have raw_post_data set, just use it as the body.
        if (isset($this->raw_post_data)) {
            $this->setHeaders(self::CONTENT_LENGTH, strlen($this->raw_post_data));
            return $this->raw_post_data;
        }

        $body = '';

        // If we have files to upload, force enctype to multipart/form-data
        if (count ($this->files) > 0) {
            $this->setEncType(self::ENC_FORMDATA);
        }

        // If we have POST parameters or files, encode and add them to the body
        if (count($this->paramsPost) > 0 || count($this->files) > 0) {
            switch($this->enctype) {
                case self::ENC_FORMDATA:
                    // Encode body as multipart/form-data
                    $boundary = '---ZENDHTTPCLIENT-' . md5(microtime());
                    $this->setHeaders(self::CONTENT_TYPE, self::ENC_FORMDATA . "; boundary={$boundary}");

                    // Get POST parameters and encode them
                    $params = $this->_getParametersRecursive($this->paramsPost);
                    foreach ($params as $pp) {
                        $body .= self::encodeFormData($boundary, $pp[0], $pp[1]);
                    }

                    // Encode files
                    foreach ($this->files as $name => $file) {
                        $fhead = array(self::CONTENT_TYPE => $file[1]);
                        $body .= self::encodeFormData($boundary, $name, $file[2], $file[0], $fhead);
                    }

                    $body .= "--{$boundary}--\r\n";
                    break;

                case self::ENC_URLENCODED:
                    // Encode body as application/x-www-form-urlencoded
                    $this->setHeaders(self::CONTENT_TYPE, self::ENC_URLENCODED);
                    $body = http_build_query($this->paramsPost, '', '&');
                    break;

                default:
                    /** @see Zend_Http_Client_Exception */
                    require_once 'Zend/Http/Client/Exception.php';
                    throw new Zend_Http_Client_Exception("Cannot handle content type '{$this->enctype}' automatically." .
                        " Please use Zend_Http_Client::setRawData to send this kind of content.");
                    break;
            }
        }
        
        // Set the Content-Length if we have a body or if request is POST/PUT
        if ($body || $this->method == self::POST || $this->method == self::PUT) {
            $this->setHeaders(self::CONTENT_LENGTH, strlen($body));
        }

        return $body;
    }
1141231
private function generateBody()
    {
        $data = $this->readHelpGuide();
        $this->version = $data['version'];
        foreach ($data['help'] as $key => $value) {
            $data = [$key, $value];
            array_push($this->body, $data);
        }

    }
1349742
public function getParsedBody()
    {
        $content_type = $this->getHeaderLine('content-type');
        $method = $this->getServerParam('REQUEST_METHOD');

        if ('POST' === $method && (false !== \strpos($content_type, 'application/x-www-form-urlencoded') || false !== \strpos($content_type, 'multipart/form-data'))) {
            return $this->post;
        }

        $body = (string) $this->body;

        if ('' === $body) {
            return;
        }

        if (false !== \strpos($content_type, 'application/json')) {
            return \Owl\safe_json_decode($body, true);
        }

        return $body;
    }
1139573
public function getBody()
    {
        if ($this->getAttachments()) {
            try {
                return $this->getParser()->getMessageBody('html');
            } catch (\Throwable $exc) {
                error_log($exc);
            }
        }
        return parent::getBody();
    }
250355
protected function getBody()
    {
        $objNew = new \stdClass();
        $i = 1;
        $subType = new SubtypeBody();
        foreach ($this->getSections(self::SECTION_BODY) as $section) {
            $obj = $this->getSection($section, array('class' => $subType));
            $subtype = strtolower($obj->__get('structure')->subtype);
            if (!isset($objNew->$subtype)) {
                $objNew->$subtype = $obj;
            } else {
                $subtype = $subtype.'_'.$i;
                $objNew->$subtype = $obj;
                $i++;
            }
            $objNew->info[] = $obj;
            $objNew->types[] = $subtype;
            /*
             * Set charset
             */
            foreach ($objNew->$subtype->__get('structure')->parameters as $parameter) {
                $attribute = strtolower($parameter->attribute);
                if ($attribute === 'charset') {
                    $value = strtolower($parameter->value);
                    /*
                     * Here must be array, but
                     */
                    //$objNew->$subtype->charset[] = $value;
                    $objNew->$subtype->charset = $value;
                }
            }
        }
        if (isset($objNew->plain)) {
            switch ($objNew->plain->structure->encoding) {
                case 3:
                    $objNew->text = imap_base64(mb_convert_encoding( $objNew->plain, "utf-8", $objNew->plain->charset ));
                    break;
                default:
                    $objNew->text = quoted_printable_decode(mb_convert_encoding( $objNew->plain, "utf-8", $objNew->plain->charset ));
                    break;
            }
            $objNew->types[] = 'text';
        } else {
            $objNew->text = null;
        }
        $this->message = $objNew;
    }
911672
public function getHtmlBody()
    {
        $xpath = new DOMXPath($this->_doc);
        $bodyNodes = $xpath->query('/html/body')->item(0)->childNodes;

        $outputFragments = array();
        for ($count = 0; $count < $bodyNodes->length; $count++) {
            $outputFragments[] = $this->_doc->saveXML($bodyNodes->item($count));
        }

        return implode($outputFragments);
    }
486260
public function getBody() {
        if (!isset($this->body)) {
            $contentType = $this->getHeader('Content-Type');

            if (stripos($contentType, 'application/json') !== false) {
                $this->body = json_decode($this->rawBody, true);
            } else {
                $this->body = $this->rawBody;
            }
        }
        return $this->body;
    }
1201520
protected function prepare()
    {
        if ($this->bodyRange !== null) {
            return;
        }

        if (isset($this->formatters[$this->format])) {
            $formatter = $this->formatters[$this->format];
            if (!is_object($formatter)) {
                $this->formatters[$this->format] = $formatter = Yii::createObject($formatter);
            }
            if ($formatter instanceof ResponseFormatterInterface) {
                $formatter->format($this);
                return;
            }
            throw new InvalidConfigException("The '{$this->format}' response formatter is invalid. It must implement the ResponseFormatterInterface.");
        } elseif ($this->format !== self::FORMAT_RAW) {
            throw new InvalidConfigException("Unsupported response format: {$this->format}");
        }

        if ($this->data !== null) {
            if (is_array($this->data)) {
                throw new InvalidArgumentException('Response raw data must not be an array.');
            } elseif (is_object($this->data)) {
                if (method_exists($this->data, '__toString')) {
                    $content = $this->data->__toString();
                } else {
                    throw new InvalidArgumentException('Response raw data must be a string or an object implementing '
                        . ' __toString().');
                }
            } else {
                $content = $this->data;
            }

            $body = new MemoryStream();
            $body->write($content);
            $this->setBody($body);
        }
    }