-
-
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -68,7 +68,7 @@ final class MultipartParser | |
private $emptyCount = 0; | ||
|
||
/** | ||
* @param int|null $uploadMaxFilesize | ||
* @param int|string|null $uploadMaxFilesize | ||
* @param int|null $maxFileUploads | ||
*/ | ||
public function __construct($uploadMaxFilesize = null, $maxFileUploads = null) | ||
|
@@ -83,10 +83,10 @@ public function __construct($uploadMaxFilesize = null, $maxFileUploads = null) | |
} | ||
|
||
if ($uploadMaxFilesize === null) { | ||
$uploadMaxFilesize = IniUtil::iniSizeToBytes(ini_get('upload_max_filesize')); | ||
$uploadMaxFilesize = ini_get('upload_max_filesize'); | ||
} | ||
|
||
$this->uploadMaxFilesize = (int)$uploadMaxFilesize; | ||
$this->uploadMaxFilesize = IniUtil::iniSizeToBytes($uploadMaxFilesize); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. Done 👍 |
||
$this->maxFileUploads = $maxFileUploads === null ? (ini_get('file_uploads') === '' ? 0 : (int)ini_get('max_file_uploads')) : (int)$maxFileUploads; | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,18 +14,19 @@ final class RequestBodyBufferMiddleware | |
private $sizeLimit; | ||
|
||
/** | ||
* @param int|null $sizeLimit Either an int with the max request body size | ||
* 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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. Good catch, done 👍 |
||
* in bytes or an ini like size string | ||
* or null to use post_max_size from PHP's | ||
* configuration. (Note that the value from | ||
* the CLI configuration will be used.) | ||
*/ | ||
public function __construct($sizeLimit = null) | ||
{ | ||
if ($sizeLimit === null) { | ||
$sizeLimit = IniUtil::iniSizeToBytes(ini_get('post_max_size')); | ||
$sizeLimit = ini_get('post_max_size'); | ||
} | ||
|
||
$this->sizeLimit = $sizeLimit; | ||
$this->sizeLimit = IniUtil::iniSizeToBytes($sizeLimit); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. Done 👍 |
||
} | ||
|
||
public function __invoke(ServerRequestInterface $request, $stack) | ||
|
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