Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
* develop:
  specify next release
  fix loading the multipart files in memory
  fix psalm error
  CS
  • Loading branch information
Baptouuuu committed Mar 27, 2024
2 parents 3a9f236 + 7d2e0fc commit f301457
Show file tree
Hide file tree
Showing 40 changed files with 22 additions and 80 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## 7.0.1 - 2024-03-27

### Fixed

- Files used in `Innmind\Http\Content\Multipart` are no longer loaded in memory

## 7.0.0 - 2023-10-22

### Changed
Expand Down
4 changes: 3 additions & 1 deletion src/Content/Multipart/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ private function headers(): Sequence
{
$name = $this->file->name()->toString();
$mediaType = $this->file->mediaType()->toString();
$headers = Sequence::of(
// Use a lazy Sequence here to prevent loading the whole file in memory
// when the the chunks are appended to the headers in self::chunks()
$headers = Sequence::lazyStartingWith(
Str::of("Content-Disposition: form-data; name=\"{$this->name}\"; filename=\"$name\"\r\n"),
Str::of("Content-Type: $mediaType\r\n"),
);
Expand Down
6 changes: 1 addition & 5 deletions src/Factory/Files/FilesFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
Factory\FilesFactory as FilesFactoryInterface,
ServerRequest\Files,
File\Status,
Exception\LogicException,
};
use Innmind\MediaType\MediaType;
use Innmind\Filesystem\{
Expand All @@ -17,10 +16,7 @@
use Innmind\Url\Path;
use Innmind\IO\IO;
use Innmind\Stream\Capabilities;
use Innmind\Immutable\{
Map,
Either,
};
use Innmind\Immutable\Either;

/**
* @psalm-immutable
Expand Down
1 change: 0 additions & 1 deletion src/Factory/Header/AcceptFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
use Innmind\Immutable\{
Str,
Maybe,
Sequence,
};

/**
Expand Down
5 changes: 1 addition & 4 deletions src/Factory/Header/DelegationFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@

namespace Innmind\Http\Factory\Header;

use Innmind\Http\{
Factory\HeaderFactory,
Header,
};
use Innmind\Http\Factory\HeaderFactory;
use Innmind\Immutable\{
Map,
Str,
Expand Down
5 changes: 1 addition & 4 deletions src/Factory/Header/HeaderFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@
Header,
Header\Value,
};
use Innmind\Immutable\{
Str,
Maybe,
};
use Innmind\Immutable\Str;

/**
* @psalm-immutable
Expand Down
1 change: 0 additions & 1 deletion src/Factory/Header/HeadersFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
Factory\HeadersFactory as HeadersFactoryInterface,
Factory\HeaderFactory as HeaderFactoryInterface,
Headers,
Header,
};
use Innmind\Immutable\Str;

Expand Down
1 change: 0 additions & 1 deletion src/Header/LinkValue.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
use Innmind\Immutable\{
Str,
Map,
Sequence,
Maybe,
};

Expand Down
10 changes: 4 additions & 6 deletions src/ResponseSender.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,13 @@

use Innmind\Http\{
Header\Date,
Header\DateValue,
Header\SetCookie,
Header\CookieValue,
Header\Parameter,
TimeContinuum\Format\Http,
Exception\LogicException,
};
use Innmind\TimeContinuum\Clock;
use Innmind\Immutable\{
Sequence,
Str,
};

final class ResponseSender implements Sender
{
Expand Down Expand Up @@ -94,7 +89,10 @@ static function(array $parameters, Parameter $parameter): array {
)->getTimestamp();
// MaxAge has precedence
/** @psalm-suppress MixedAssignment */
$parameters['expire'] = ($parameters['expire'] ?? 0 !== 0) ? $parameters['expire'] : $timestamp;
$parameters['expire'] = match ($parameters['expire'] ?? 0) {
0 => $timestamp,
default => $parameters['expire'] ?? 0,
};
break;

case 'Max-Age':
Expand Down
4 changes: 0 additions & 4 deletions tests/Factory/Files/FilesFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@
};
use Innmind\IO\IO;
use Innmind\Stream\Streams;
use Innmind\Immutable\{
Map,
MapInterface
};
use PHPUnit\Framework\TestCase;

class FilesFactoryTest extends TestCase
Expand Down
3 changes: 1 addition & 2 deletions tests/Factory/Header/FactoriesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@

use Innmind\Http\Factory\{
Header\Factories,
Header\DelegationFactory,
HeaderFactory
Header\DelegationFactory
};
use Innmind\TimeContinuum\Earth\Clock;
use Innmind\Immutable\Map;
Expand Down
1 change: 0 additions & 1 deletion tests/Header/AcceptCharsetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
use Innmind\Http\{
Header\AcceptCharset,
Header,
Header\Value,
Header\AcceptCharsetValue,
Header\Parameter\Quality
};
Expand Down
1 change: 0 additions & 1 deletion tests/Header/AcceptRangesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
use Innmind\Http\{
Header\AcceptRanges,
Header,
Header\Value,
Header\AcceptRangesValue
};
use Innmind\Immutable\Set;
Expand Down
1 change: 0 additions & 1 deletion tests/Header/AcceptRangesValueTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
use Innmind\Http\{
Header\AcceptRangesValue,
Header\Value,
Header\Parameter\Quality,
Exception\DomainException,
};
use PHPUnit\Framework\TestCase;
Expand Down
7 changes: 1 addition & 6 deletions tests/Header/AcceptTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,7 @@
Header\Accept,
Header,
Header\AcceptValue,
Header\Parameter\Quality,
Header\Parameter
};
use Innmind\Immutable\{
Set,
Map
Header\Parameter\Quality
};
use PHPUnit\Framework\TestCase;

Expand Down
1 change: 0 additions & 1 deletion tests/Header/AgeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
use Innmind\Http\{
Header\Age,
Header,
Header\Value,
Header\AgeValue
};
use Innmind\Immutable\Set;
Expand Down
1 change: 0 additions & 1 deletion tests/Header/AllowValueTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
use Innmind\Http\Header\{
AllowValue,
Value,
Parameter\Quality,
};
use PHPUnit\Framework\TestCase;

Expand Down
1 change: 0 additions & 1 deletion tests/Header/AuthorizationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
use Innmind\Http\{
Header\Authorization,
Header,
Header\Value,
Header\AuthorizationValue
};
use Innmind\Immutable\Set;
Expand Down
4 changes: 0 additions & 4 deletions tests/Header/CacheControlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@
Header,
Header\CacheControlValue\PublicCache
};
use Innmind\Immutable\{
Set,
Map
};
use PHPUnit\Framework\TestCase;

class CacheControlTest extends TestCase
Expand Down
1 change: 0 additions & 1 deletion tests/Header/ContentEncodingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
use Innmind\Http\{
Header\ContentEncoding,
Header,
Header\Value,
Header\ContentEncodingValue
};
use Innmind\Immutable\Set;
Expand Down
1 change: 0 additions & 1 deletion tests/Header/ContentLengthTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
use Innmind\Http\{
Header\ContentLength,
Header,
Header\Value,
Header\ContentLengthValue
};
use Innmind\Immutable\Set;
Expand Down
1 change: 0 additions & 1 deletion tests/Header/ContentLocationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
use Innmind\Http\{
Header\ContentLocation,
Header,
Header\Value,
Header\LocationValue
};
use Innmind\Immutable\Set;
Expand Down
1 change: 0 additions & 1 deletion tests/Header/ContentRangeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
use Innmind\Http\{
Header\ContentRange,
Header,
Header\Value,
Header\ContentRangeValue
};
use Innmind\Immutable\Set;
Expand Down
6 changes: 1 addition & 5 deletions tests/Header/ContentTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,10 @@
use Innmind\Http\{
Header\ContentType,
Header,
Header\Value,
Header\ContentTypeValue,
Header\Parameter
};
use Innmind\Immutable\{
Set,
Map,
};
use Innmind\Immutable\Set;
use PHPUnit\Framework\TestCase;

class ContentTypeTest extends TestCase
Expand Down
1 change: 0 additions & 1 deletion tests/Header/CookieTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
use Innmind\Http\{
Header\Cookie,
Header,
Header\Value,
Header\CookieValue,
Header\Parameter\Parameter
};
Expand Down
1 change: 0 additions & 1 deletion tests/Header/DateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
use Innmind\Http\{
Header\Date,
Header,
Header\Value,
Header\DateValue
};
use Innmind\TimeContinuum\Earth\PointInTime\PointInTime;
Expand Down
1 change: 0 additions & 1 deletion tests/Header/ExpiresTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
use Innmind\Http\{
Header\Expires,
Header,
Header\Value,
Header\DateValue
};
use Innmind\TimeContinuum\Earth\PointInTime\PointInTime;
Expand Down
1 change: 0 additions & 1 deletion tests/Header/HostTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
use Innmind\Http\{
Header\Host,
Header,
Header\Value,
Header\HostValue
};
use Innmind\Immutable\Set;
Expand Down
1 change: 0 additions & 1 deletion tests/Header/IfModifiedSinceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
use Innmind\Http\{
Header\IfModifiedSince,
Header,
Header\Value,
Header\DateValue
};
use Innmind\TimeContinuum\Earth\PointInTime\PointInTime;
Expand Down
1 change: 0 additions & 1 deletion tests/Header/IfUnmodifiedSinceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
use Innmind\Http\{
Header\IfUnmodifiedSince,
Header,
Header\Value,
Header\DateValue
};
use Innmind\TimeContinuum\Earth\PointInTime\PointInTime;
Expand Down
1 change: 0 additions & 1 deletion tests/Header/LastModifiedTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
use Innmind\Http\{
Header\LastModified,
Header,
Header\Value,
Header\DateValue
};
use Innmind\TimeContinuum\Earth\PointInTime\PointInTime;
Expand Down
4 changes: 0 additions & 4 deletions tests/Header/LinkTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@
Header\Parameter
};
use Innmind\Url\Url;
use Innmind\Immutable\{
Set,
Map
};
use PHPUnit\Framework\TestCase;

class LinkTest extends TestCase
Expand Down
1 change: 0 additions & 1 deletion tests/Header/LocationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
use Innmind\Http\{
Header\Location,
Header,
Header\Value,
Header\LocationValue
};
use Innmind\Immutable\Set;
Expand Down
1 change: 0 additions & 1 deletion tests/Header/RangeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
use Innmind\Http\{
Header\Range,
Header,
Header\Value,
Header\RangeValue
};
use Innmind\Immutable\Set;
Expand Down
1 change: 0 additions & 1 deletion tests/Header/ReferrerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
use Innmind\Http\{
Header\Referrer,
Header,
Header\Value,
Header\ReferrerValue
};
use Innmind\Immutable\Set;
Expand Down
1 change: 0 additions & 1 deletion tests/Header/SetCookieTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
use Innmind\Http\{
Header\SetCookie,
Header,
Header\Value,
Header\CookieValue,
Header\Parameter\Parameter,
Header\CookieParameter\Secure
Expand Down
3 changes: 1 addition & 2 deletions tests/Header/WWWAuthenticateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
use Innmind\Http\{
Header\WWWAuthenticate,
Header\WWWAuthenticateValue,
Header,
Header\Value
Header
};
use Innmind\Immutable\Set;
use PHPUnit\Framework\TestCase;
Expand Down
1 change: 0 additions & 1 deletion tests/HeadersTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
Header\Allow,
Header\ContentType,
Header\ContentTypeValue,
Header\Parameter,
Header\Value\Value,
};
use Innmind\Immutable\SideEffect;
Expand Down
5 changes: 1 addition & 4 deletions tests/Response/StatusCodeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@

use Innmind\Http\Response\StatusCode;
use PHPUnit\Framework\TestCase;
use Innmind\BlackBox\{
PHPUnit\BlackBox,
Set,
};
use Innmind\BlackBox\PHPUnit\BlackBox;

class StatusCodeTest extends TestCase
{
Expand Down
Loading

0 comments on commit f301457

Please sign in to comment.