Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. HttpClientKernel.php

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\HttpKernel

Code

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);
}
RSS feed
Powered by Drupal