diff --git a/src/Command/Extension/UploadExtensionVersionCommand.php b/src/Command/Extension/UploadExtensionVersionCommand.php index e0b7c8d..3c06f10 100644 --- a/src/Command/Extension/UploadExtensionVersionCommand.php +++ b/src/Command/Extension/UploadExtensionVersionCommand.php @@ -24,6 +24,7 @@ use TYPO3\Tailor\Filesystem; use TYPO3\Tailor\Formatter\ConsoleFormatter; use TYPO3\Tailor\Helper\CommandHelper; +use TYPO3\Tailor\HttpClientFactory; use TYPO3\Tailor\Service\VersionService; /** @@ -75,8 +76,11 @@ protected function getRequestConfiguration(): RequestConfiguration 'POST', 'extension/' . $this->extensionKey . '/' . $this->version, [], - $formDataPart->bodyToIterable(), - $formDataPart->getPreparedHeaders()->toArray() + [], + [], + false, + HttpClientFactory::ALL_AUTH, + $formDataPart ); } diff --git a/src/Dto/RequestConfiguration.php b/src/Dto/RequestConfiguration.php index 18c976e..47cf070 100644 --- a/src/Dto/RequestConfiguration.php +++ b/src/Dto/RequestConfiguration.php @@ -12,6 +12,7 @@ namespace TYPO3\Tailor\Dto; +use Symfony\Component\Mime\Part\Multipart\FormDataPart; use TYPO3\Tailor\HttpClientFactory; /** @@ -35,6 +36,9 @@ class RequestConfiguration /** @var iterable */ protected $body; + /** @var FormDataPart|null */ + protected $formData; + /** @var iterable */ protected $headers; @@ -54,7 +58,8 @@ public function __construct( iterable $body = [], iterable $headers = [], bool $raw = false, - int $defaultAuthMethod = HttpClientFactory::ALL_AUTH + int $defaultAuthMethod = HttpClientFactory::ALL_AUTH, + ?FormDataPart $formData = null ) { $this->method = $method; $this->endpoint = $endpoint; @@ -63,6 +68,7 @@ public function __construct( $this->headers = $headers; $this->raw = $raw; $this->defaultAuthMethod = $defaultAuthMethod; + $this->formData = $formData; } public function getMethod(): string @@ -85,9 +91,20 @@ public function getBody(): iterable return $this->body; } + public function getFormData(): ?FormDataPart + { + return $this->formData; + } + public function getHeaders(): iterable { - return $this->headers; + $headers = $this->headers; + if ($this->formData) { + foreach ($this->formData->getPreparedHeaders()->all() as $key => $value) { + $headers[$key] = $value->getBodyAsString(); + } + } + return $headers; } public function setRaw(bool $raw): self diff --git a/src/HttpClientFactory.php b/src/HttpClientFactory.php index cffa215..00334f7 100644 --- a/src/HttpClientFactory.php +++ b/src/HttpClientFactory.php @@ -48,6 +48,8 @@ public static function create(RequestConfiguration $requestConfiguration): HttpC } if ($requestConfiguration->getBody() !== []) { $options['body'] = $requestConfiguration->getBody(); + } elseif ($requestConfiguration->getFormData()) { + $options['body'] = $requestConfiguration->getFormData()->bodyToString(); } if (($defaultAuthMethod === self::BEARER_AUTH || $defaultAuthMethod === self::ALL_AUTH) && Variables::has('TYPO3_API_TOKEN')