/** * Prepares the body. * * @param \Ivory\HttpAdapter\Message\InternalRequestInterface $internalRequest The internal request. * * @return string The prepared body. */ protected function prepareBody(InternalRequestInterface $internalRequest) { if ($internalRequest->hasRawDatas()) { return $internalRequest->getRawDatas(); } if (!$internalRequest->hasFiles()) { return http_build_query($internalRequest->getDatas(), null, '&'); } $body = ''; foreach ($internalRequest->getDatas() as $name => $value) { $body .= $this->prepareRawBody($name, $value); } foreach ($internalRequest->getFiles() as $name => $file) { $body .= $this->prepareRawBody($name, $file, true); } $body .= '--' . $this->configuration->getBoundary() . '--' . "\r\n"; return $body; }
/** * {@inheritdoc} */ public function formatRequest(InternalRequestInterface $request) { return array('protocol_version' => $request->getProtocolVersion(), 'url' => (string) $request->getUrl(), 'method' => $request->getMethod(), 'headers' => $request->getHeaders(), 'raw_datas' => $request->getRawDatas(), 'datas' => $request->getDatas(), 'files' => $request->getFiles(), 'parameters' => $request->getParameters()); }