-
-
Notifications
You must be signed in to change notification settings - Fork 160
Allow ini-like filesize for RequestBodyBufferMiddleware and MultipartParser #278
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Functionally LGTM, needs some documentation and tests though 👍
tests/Io/MultipartParserTest.php
Outdated
@@ -696,14 +696,14 @@ public function testUploadTooLargeFile() | |||
$data .= "Content-Disposition: form-data; name=\"file\"; filename=\"hello\"\r\n"; | |||
$data .= "Content-type: text/plain\r\n"; | |||
$data .= "\r\n"; | |||
$data .= "world\r\n"; | |||
$data .= str_repeat('world', 1024) . "\r\n"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test makes perfect sense to me, but I feel that this is a bit misplaced here. Maybe add a separate test case for this? 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done 👍
} | ||
|
||
$this->sizeLimit = $sizeLimit; | ||
$this->sizeLimit = IniUtil::iniSizeToBytes($sizeLimit); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, but doesn't match docblock/documentation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done 👍
} | ||
|
||
$this->uploadMaxFilesize = (int)$uploadMaxFilesize; | ||
$this->uploadMaxFilesize = IniUtil::iniSizeToBytes($uploadMaxFilesize); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, but doesn't match docblock/documentation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done 👍
@clue updated and added docs and tests |
And fixed the test error that just came up 😊 |
'GET', | ||
'https://example.com/', | ||
array(), | ||
new HttpBodyStream($stream, 2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does the 2 make sense here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, sementically no, doesn't make sense. Practically doesn't make a difference though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed it anyway 👍
@@ -68,7 +68,7 @@ | |||
private $emptyCount = 0; | |||
|
|||
/** | |||
* @param int|null $uploadMaxFilesize | |||
* @param int|string|null $uploadMaxFilesize |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, same change is required for RequestBodyParserMiddleware
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
'GET', | ||
'https://example.com/', | ||
array(), | ||
new HttpBodyStream($stream, 2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, sementically no, doesn't make sense. Practically doesn't make a difference though.
* configuration. (Note that the value from | ||
* the CLI configuration will be used.) | ||
* @param int|string|null $sizeLimit Either an int with the max request body size | ||
* or an ini like sze string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sze -> size. Also, maybe mention an example like 8M
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed 👍
* or null to use post_max_size from PHP's | ||
* configuration. (Note that the value from | ||
* the CLI configuration will be used.) | ||
* @param int|string|null $sizeLimit Either an int with the max request body size |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe "...body size in bytes..."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, done 👍
Split off from #276
Implements / closes #275