forked from symfony/symfony
-
Notifications
You must be signed in to change notification settings - Fork 3
[HttpClient] Add support for amphp/http-client v5 #43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 1 commit
Commits
Show all changes
46 commits
Select commit
Hold shift + click to select a range
7e62355
chore: simplify PHP CS Fixer config
keradus c24e3e7
[Validator] Simplify `NoSuspiciousCharactersValidator`
MatTheCat f8611cf
minor #54062 [Validator] Simplify `NoSuspiciousCharactersValidator` (…
nicolas-grekas dfb41cd
[Mailer][Brevo] Remove tags from mandatory event arguments
palgalik 182e93e
bug #54089 [Mailer] [Brevo] Remove tags from mandatory event argument…
fabpot 9407a1b
[HttpClient] Fix deprecation on PHP 8.3
nicolas-grekas 3a02e21
minor #54073 chore: simplify PHP CS Fixer config (keradus)
fabpot bb7c711
bug #54102 [HttpClient] Fix deprecation on PHP 8.3 (nicolas-grekas)
derrabus ae16b2d
[AssetMapper] Fix `JavaScriptImportPathCompiler` regression in regex
PhilETaylor 91278da
bug #54079 [AssetMapper] Fix `JavaScriptImportPathCompiler` regressio…
nicolas-grekas 5f959e2
Remove undefined variable
smnandre 0478d54
[Clock] Add PHPUnit 10 attributes
ruudk ff08e9e
bug #54129 [Clock] Add attributes to support PHPUnit 10 + 11 (ruudk)
nicolas-grekas 4155f66
[Security][Tests] Update functional tests to better reflect end-user …
llupa 1f386a3
minor #54086 [Security][Tests] Update functional tests to better refl…
chalasr a184a18
Merge branch '5.4' into 6.4
wouterj e770fba
Merge branch '6.4' into 7.0
wouterj 9482c97
Merge branch '7.0' into 7.1
wouterj 9af1f34
[AssetMapper] Deprecate unused method `splitPackageNameAndFilePath`
smnandre 31a9b35
feature #54125 [AssetMapper] Deprecate unused method `splitPackageNam…
fabpot 4d120b8
[HttpClient] Preserve float in JsonMockResponse
Jibbarth 24cf1eb
minor #54122 [AssetMapper] Remove undefined $path variable (smnandre)
fabpot 2333b58
[AssetMapper] Throw exception in Javascript compiler when PCRE error
smnandre 5f78910
bug #54113 [AssetMapper] Throw exception in Javascript compiler when …
fabpot 3c39c04
Merge branch '6.4' into 7.0
fabpot f208ca7
Merge branch '7.0' into 7.1
fabpot fdb0340
[Mailer] Simplify MailerTestCommand
lyrixx 9d6ee30
minor #54110 [Mailer] Simplify MailerTestCommand (lyrixx)
fabpot 9b03f27
Update CHANGELOG for 5.4.37
fabpot 8d1867d
Update CONTRIBUTORS for 5.4.37
fabpot 3e40319
Update VERSION for 5.4.37
fabpot 3f8d2f1
Merge pull request #54157 from fabpot/release-5.4.37
fabpot 2ed7af7
Bump Symfony version to 5.4.38
fabpot b9da773
Update CHANGELOG for 6.4.5
fabpot e394573
Update VERSION for 6.4.5
fabpot 86b66dc
Merge pull request #54158 from fabpot/release-6.4.5
fabpot 75bafd2
Bump Symfony version to 6.4.6
fabpot 47d722b
Update CHANGELOG for 7.0.5
fabpot f3ecda4
Update VERSION for 7.0.5
fabpot aa77387
Merge pull request #54159 from fabpot/release-7.0.5
fabpot cdb3fdd
Bump Symfony version to 7.0.6
fabpot f5b5e14
Merge branch '5.4' into 6.4
derrabus 0523300
bug #54146 [HttpClient] Preserve float in JsonMockResponse (Jibbarth)
derrabus e37f57b
Merge branch '6.4' into 7.0
derrabus b982c71
Merge branch '7.0' into 7.1
derrabus dac2ea7
[HttpClient] Add support for amphp/http-client v5
nicolas-grekas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev
Previous commit
[HttpClient] Add support for amphp/http-client v5
- Loading branch information
commit dac2ea7651e07b5ff332974ecb35df110acf0e14
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,6 +32,7 @@ jobs: | |
- php: '8.2' | ||
mode: low-deps | ||
- php: '8.3' | ||
- php: '8.4' | ||
#mode: experimental | ||
fail-fast: false | ||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
150 changes: 150 additions & 0 deletions
150
src/Symfony/Component/HttpClient/Internal/AmpBodyV5.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,150 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <fabien@symfony.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Symfony\Component\HttpClient\Internal; | ||
|
||
use Amp\ByteStream\ReadableBuffer; | ||
use Amp\ByteStream\ReadableIterableStream; | ||
use Amp\ByteStream\ReadableResourceStream; | ||
use Amp\ByteStream\ReadableStream; | ||
use Amp\Cancellation; | ||
use Amp\Http\Client\HttpContent; | ||
use Symfony\Component\HttpClient\Exception\TransportException; | ||
|
||
/** | ||
* @author Nicolas Grekas <p@tchwork.com> | ||
* | ||
* @internal | ||
*/ | ||
class AmpBodyV5 implements HttpContent, ReadableStream, \IteratorAggregate | ||
{ | ||
private ReadableStream $body; | ||
private ?string $content; | ||
private array $info; | ||
private ?int $offset = 0; | ||
private int $length = -1; | ||
private ?int $uploaded = null; | ||
|
||
/** | ||
* @param \Closure|resource|string $body | ||
*/ | ||
public function __construct( | ||
$body, | ||
&$info, | ||
private \Closure $onProgress, | ||
) { | ||
$this->info = &$info; | ||
|
||
if (\is_resource($body)) { | ||
$this->offset = ftell($body); | ||
$this->length = fstat($body)['size']; | ||
$this->body = new ReadableResourceStream($body); | ||
} elseif (\is_string($body)) { | ||
$this->length = \strlen($body); | ||
$this->body = new ReadableBuffer($body); | ||
$this->content = $body; | ||
} else { | ||
$this->body = new ReadableIterableStream((static function () use ($body) { | ||
while ('' !== $data = ($body)(16372)) { | ||
if (!\is_string($data)) { | ||
throw new TransportException(sprintf('Return value of the "body" option callback must be string, "%s" returned.', get_debug_type($data))); | ||
} | ||
|
||
yield $data; | ||
} | ||
})()); | ||
} | ||
} | ||
|
||
public function getContent(): ReadableStream | ||
{ | ||
if (null !== $this->uploaded) { | ||
$this->uploaded = null; | ||
|
||
if (\is_string($this->body)) { | ||
$this->offset = 0; | ||
} elseif ($this->body instanceof ReadableResourceStream) { | ||
fseek($this->body->getResource(), $this->offset); | ||
} | ||
} | ||
|
||
return $this; | ||
} | ||
|
||
public function getContentType(): ?string | ||
{ | ||
return null; | ||
} | ||
|
||
public function getContentLength(): ?int | ||
{ | ||
return 0 <= $this->length ? $this->length - $this->offset : null; | ||
} | ||
|
||
public function read(Cancellation $cancellation = null): ?string | ||
{ | ||
$this->info['size_upload'] += $this->uploaded; | ||
$this->uploaded = 0; | ||
($this->onProgress)(); | ||
|
||
if (null !== $data = $this->body->read($cancellation)) { F438 span> | ||
$this->uploaded = \strlen($data); | ||
} else { | ||
$this->info['upload_content_length'] = $this->info['size_upload']; | ||
} | ||
|
||
return $data; | ||
} | ||
|
||
public function isReadable(): bool | ||
{ | ||
return $this->body->isReadable(); | ||
} | ||
|
||
public function close(): void | ||
{ | ||
$this->body->close(); | ||
} | ||
|
||
public function isClosed(): bool | ||
{ | ||
return $this->body->isClosed(); | ||
} | ||
|
||
public function onClose(\Closure $onClose): void | ||
{ | ||
$this->body->onClose($onClose); | ||
} | ||
|
||
public function getIterator(): \Traversable | ||
{ | ||
return $this->body; | ||
} | ||
|
||
public static function rewind(HttpContent $body): HttpContent | ||
{ | ||
if (!$body instanceof self) { | ||
return $body; | ||
} | ||
|
||
$body->uploaded = null; | ||
|
||
if ($body->body instanceof ReadableResourceStream && !$body->body->isClosed()) { | ||
fseek($body->body->getResource(), $body->offset); | ||
} | ||
|
||
if ($body->body instanceof ReadableBuffer) { | ||
return new $body($body->content, $body->info, $body->onProgress); | ||
} | ||
|
||
return $body; | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.