mirror of
https://github.com/Combodo/iTop.git
synced 2026-05-23 01:02:16 +02:00
N°5809 Update guzzlehttp/guzzle from 7.7.0 to 7.8.1
This commit is contained in:
@@ -51,7 +51,7 @@ final class MultipartStream implements StreamInterface
|
||||
/**
|
||||
* Get the headers needed before transferring the content of a POST file
|
||||
*
|
||||
* @param array<string, string> $headers
|
||||
* @param string[] $headers
|
||||
*/
|
||||
private function getHeaders(array $headers): string
|
||||
{
|
||||
@@ -60,7 +60,7 @@ final class MultipartStream implements StreamInterface
|
||||
$str .= "{$key}: {$value}\r\n";
|
||||
}
|
||||
|
||||
return "--{$this->boundary}\r\n" . trim($str) . "\r\n\r\n";
|
||||
return "--{$this->boundary}\r\n".trim($str)."\r\n\r\n";
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -72,7 +72,7 @@ final class MultipartStream implements StreamInterface
|
||||
|
||||
foreach ($elements as $element) {
|
||||
if (!is_array($element)) {
|
||||
throw new \UnexpectedValueException("An array is expected");
|
||||
throw new \UnexpectedValueException('An array is expected');
|
||||
}
|
||||
$this->addElement($stream, $element);
|
||||
}
|
||||
@@ -112,10 +112,15 @@ final class MultipartStream implements StreamInterface
|
||||
$stream->addStream(Utils::streamFor("\r\n"));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string[] $headers
|
||||
*
|
||||
* @return array{0: StreamInterface, 1: string[]}
|
||||
*/
|
||||
private function createElement(string $name, StreamInterface $stream, ?string $filename, array $headers): array
|
||||
{
|
||||
// Set a default content-disposition header if one was no provided
|
||||
$disposition = $this->getHeader($headers, 'content-disposition');
|
||||
$disposition = self::getHeader($headers, 'content-disposition');
|
||||
if (!$disposition) {
|
||||
$headers['Content-Disposition'] = ($filename === '0' || $filename)
|
||||
? sprintf(
|
||||
@@ -127,7 +132,7 @@ final class MultipartStream implements StreamInterface
|
||||
}
|
||||
|
||||
// Set a default content-length header if one was no provided
|
||||
$length = $this->getHeader($headers, 'content-length');
|
||||
$length = self::getHeader($headers, 'content-length');
|
||||
if (!$length) {
|
||||
if ($length = $stream->getSize()) {
|
||||
$headers['Content-Length'] = (string) $length;
|
||||
@@ -135,21 +140,22 @@ final class MultipartStream implements StreamInterface
|
||||
}
|
||||
|
||||
// Set a default Content-Type if one was not supplied
|
||||
$type = $this->getHeader($headers, 'content-type');
|
||||
$type = self::getHeader($headers, 'content-type');
|
||||
if (!$type && ($filename === '0' || $filename)) {
|
||||
if ($type = MimeType::fromFilename($filename)) {
|
||||
$headers['Content-Type'] = $type;
|
||||
}
|
||||
$headers['Content-Type'] = MimeType::fromFilename($filename) ?? 'application/octet-stream';
|
||||
}
|
||||
|
||||
return [$stream, $headers];
|
||||
}
|
||||
|
||||
private function getHeader(array $headers, string $key)
|
||||
/**
|
||||
* @param string[] $headers
|
||||
*/
|
||||
private static function getHeader(array $headers, string $key): ?string
|
||||
{
|
||||
$lowercaseHeader = strtolower($key);
|
||||
foreach ($headers as $k => $v) {
|
||||
if (strtolower($k) === $lowercaseHeader) {
|
||||
if (strtolower((string) $k) === $lowercaseHeader) {
|
||||
return $v;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user