-
Notifications
You must be signed in to change notification settings - Fork 4
fix: httpclient - header return 100-continue and write queue with empty value #29
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
Merged
Merged
Changes from 36 commits
Commits
Show all changes
41 commits
Select commit
Hold shift + click to select a range
a766032
chore: Add .idea to .gitignore
ca127a4
chore: rectorphp was implemented and the following adjustments
6c0326e
chore: remove .idea from .gitignore and clean up configuration files
28b7de2
chore: ractor config adjustement - skip SimplifyUselessVariableRector
3e9b132
Merge branch 'thenativeweb:main' into main
wundii 1db4811
Merge branch 'thenativeweb:main' into main
wundii 5b7d8fe
Merge branch 'thenativeweb:main' into main
wundii 2553030
Merge branch 'thenativeweb:main' into main
wundii 8b8739d
Merge branch 'thenativeweb:main' into main
wundii 2e7c771
Merge branch 'thenativeweb:main' into main
wundii b636c85
Merge branch 'thenativeweb:main' into main
wundii 5bfa6bd
refactor: update classes to final and readonly, enhance container sta…
3458d2e
Merge remote-tracking branch 'origin/main'
33580dd
docs: update README to include iterator_to_array usage examples for w…
3c4cd49
docs: update README to include iterator_to_array usage examples for w…
be405de
refactor: change writeEvents return type to array and update usage in…
cb4e163
fix: curl error handling if the response header is empty
0592ac8
fix: improve error handling for cURL execution in contentIterator
2c3a119
refactor: centralize error handling in verifyCurlHandle method
70c65d9
test: enhance CurlMultiHandlerTest with header
e8411d7
refactor: rename parameter in verifyCurlHandle method for clarity
799a6f3
refactor: verifyCurlHandle
2f015bb
Merge branch 'thenativeweb:main' into main
wundii d123469
Merge branch 'refs/heads/main' into HttpClient
d2f1375
test: improve exception message matching in CurlMultiHandlerTest
79f1153
refactor: rename removeLineBrake method to removeLineBrakes for clarity
2db57ec
Merge branch 'thenativeweb:main' into main
wundii e37923a
Merge branch 'refs/heads/main' into HttpClient
4146ffb
feat: add FileUpload support for HttpClient
7d61b70
feat: add FileUpload support for HttpClient
7331c91
feat: add FileUpload support for HttpClient
d782b87
refactor: improve infinity loop handling in CurlMultiHandler and add …
77a7bb0
test: enhance CurlFactoryTest assertions for upload options
7589e75
Merge branch 'thenativeweb:main' into main
wundii 857096e
Merge branch 'refs/heads/main' into HttpClient
9ec8ead
test: rename method to clarify purpose of file upload handling
05e454e
refactor: remove FileUpload handling from CurlFactory and related tests
5ca6a7f
refactor: update body check in CurlFactory to allow null values
24ce504
Merge branch 'thenativeweb:main' into HttpClient
wundii 0ce4195
Merge branch 'thenativeweb:main' into main
wundii b69af09
Merge branch 'refs/heads/main' into HttpClient
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Thenativeweb\Eventsourcingdb\Stream; | ||
|
|
||
| use InvalidArgumentException; | ||
| use SplFileObject; | ||
|
|
||
| class FileUpload | ||
| { | ||
| private const SUPPORTED_CONTENT_TYPES = [ | ||
| 'application/x-ndjson', | ||
| ]; | ||
|
|
||
| public function __construct( | ||
| private readonly SplFileObject $splFileObject, | ||
| private readonly string $contentType = 'application/x-ndjson', | ||
| ) { | ||
| if (!$splFileObject->isReadable()) { | ||
| throw new InvalidArgumentException("The file {$this->splFileObject->getRealPath()} must be readable."); | ||
| } | ||
| } | ||
|
|
||
| public function getContentType(): string | ||
| { | ||
| if (!in_array($this->contentType, self::SUPPORTED_CONTENT_TYPES, true)) { | ||
| $supportedContentTypes = implode("', '", self::SUPPORTED_CONTENT_TYPES); | ||
| throw new InvalidArgumentException( | ||
| "Unsupported content type: '{$this->contentType}', expected '{$supportedContentTypes}'." | ||
| ); | ||
| } | ||
|
|
||
| return $this->contentType; | ||
| } | ||
|
|
||
| public function isReadable(): bool | ||
| { | ||
| return $this->splFileObject->isReadable(); | ||
| } | ||
|
|
||
| public function getRealPath(): string | ||
| { | ||
| return $this->splFileObject->getRealPath(); | ||
| } | ||
|
|
||
| public function getSize(): int | ||
| { | ||
| return $this->splFileObject->getSize(); | ||
| } | ||
|
|
||
| public function read(): string | ||
| { | ||
| return $this->splFileObject->fgets(); | ||
| } | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Stream; | ||
|
|
||
| use InvalidArgumentException; | ||
| use PHPUnit\Framework\TestCase; | ||
| use SplFileObject; | ||
| use Thenativeweb\Eventsourcingdb\Stream\FileUpload; | ||
|
|
||
| final class FileUploadTest extends TestCase | ||
| { | ||
| private string $filePath; | ||
|
|
||
| protected function setUp(): void | ||
| { | ||
| $this->filePath = tempnam(sys_get_temp_dir(), 'upload_'); | ||
| file_put_contents($this->filePath, "line1\nline2\n"); | ||
| } | ||
|
|
||
| protected function tearDown(): void | ||
| { | ||
| if (file_exists($this->filePath)) { | ||
| unlink($this->filePath); | ||
| } | ||
| } | ||
|
|
||
| public function testItConstructsSuccessfully(): void | ||
| { | ||
| $file = new SplFileObject($this->filePath, 'r'); | ||
| $fileUpload = new FileUpload($file); | ||
|
|
||
| $this->assertInstanceOf(FileUpload::class, $fileUpload); | ||
| $this->assertTrue($fileUpload->isReadable()); | ||
| } | ||
|
|
||
| public function testItThrowsWhenFileIsNotReadable(): void | ||
| { | ||
| $file = new SplFileObject('php://memory', 'r'); | ||
|
|
||
| $this->expectException(InvalidArgumentException::class); | ||
| $this->expectExceptionMessage('must be readable.'); | ||
|
|
||
| new FileUpload($file); | ||
| } | ||
|
|
||
| public function testItReturnsValidContentType(): void | ||
| { | ||
| $file = new SplFileObject($this->filePath, 'r'); | ||
| $fileUpload = new FileUpload($file, 'application/x-ndjson'); | ||
|
|
||
| $this->assertSame('application/x-ndjson', $fileUpload->getContentType()); | ||
| } | ||
|
|
||
| public function testItThrowsOnUnsupportedContentType(): void | ||
| { | ||
| $file = new SplFileObject($this->filePath, 'r'); | ||
|
|
||
| $this->expectException(InvalidArgumentException::class); | ||
| $this->expectExceptionMessage('Unsupported content type'); | ||
|
|
||
| $fileUpload = new FileUpload($file, 'text/plain'); | ||
| $fileUpload->getContentType(); | ||
| } | ||
|
|
||
| public function testItReadsFirstLine(): void | ||
| { | ||
| $file = new SplFileObject($this->filePath, 'r'); | ||
| $fileUpload = new FileUpload($file); | ||
|
|
||
| $line = $fileUpload->read(); | ||
| $this->assertSame("line1\n", $line); | ||
| } | ||
|
|
||
| public function testItReturnsFileSize(): void | ||
| { | ||
| $file = new SplFileObject($this->filePath, 'r'); | ||
| $fileUpload = new FileUpload($file); | ||
|
|
||
| $this->assertSame(filesize($this->filePath), $fileUpload->getSize()); | ||
| } | ||
|
|
||
| public function testItReturnsRealPath(): void | ||
| { | ||
| $file = new SplFileObject($this->filePath, 'r'); | ||
| $fileUpload = new FileUpload($file); | ||
|
|
||
| $this->assertSame(realpath($this->filePath), $fileUpload->getRealPath()); | ||
| } | ||
| } |
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.