Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/Command/Extension/UploadExtensionVersionCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down Expand Up @@ -75,8 +76,11 @@ protected function getRequestConfiguration(): RequestConfiguration
'POST',
'extension/' . $this->extensionKey . '/' . $this->version,
[],
$formDataPart->bodyToIterable(),
$formDataPart->getPreparedHeaders()->toArray()
[],
[],
false,
HttpClientFactory::ALL_AUTH,
$formDataPart
);
}

Expand Down
21 changes: 19 additions & 2 deletions src/Dto/RequestConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

namespace TYPO3\Tailor\Dto;

use Symfony\Component\Mime\Part\Multipart\FormDataPart;
use TYPO3\Tailor\HttpClientFactory;

/**
Expand All @@ -35,6 +36,9 @@ class RequestConfiguration
/** @var iterable */
protected $body;

/** @var FormDataPart|null */
protected $formData;

/** @var iterable */
protected $headers;

Expand All @@ -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;
Expand All @@ -63,6 +68,7 @@ public function __construct(
$this->headers = $headers;
$this->raw = $raw;
$this->defaultAuthMethod = $defaultAuthMethod;
$this->formData = $formData;
}

public function getMethod(): string
Expand All @@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/HttpClientFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down