function HttpClientKernel::getBody
1 call to HttpClientKernel::getBody()
- HttpClientKernel::handle in vendor/
symfony/ http-kernel/ HttpClientKernel.php - Handles a Request to convert it to a Response.
File
-
vendor/
symfony/ http-kernel/ HttpClientKernel.php, line 74
Class
- HttpClientKernel
- An implementation of a Symfony HTTP kernel using a "real" HTTP client.
Namespace
Symfony\Component\HttpKernelCode
private function getBody(Request $request) : ?AbstractPart {
if (\in_array($request->getMethod(), [
'GET',
'HEAD',
])) {
return null;
}
if (!class_exists(AbstractPart::class)) {
throw new \LogicException('You cannot pass non-empty bodies as the Mime component is not installed. Try running "composer require symfony/mime".');
}
if ($content = $request->getContent()) {
return new TextPart($content, 'utf-8', 'plain', '8bit');
}
$fields = $request->request
->all();
foreach ($request->files
->all() as $name => $file) {
$fields[$name] = DataPart::fromPath($file->getPathname(), $file->getClientOriginalName(), $file->getClientMimeType());
}
return new FormDataPart($fields);
}