aboutsummaryrefslogtreecommitdiffstats
path: root/includes/api/ApiMain.php
diff options
context:
space:
mode:
Diffstat (limited to 'includes/api/ApiMain.php')
-rw-r--r--includes/api/ApiMain.php18
1 files changed, 14 insertions, 4 deletions
diff --git a/includes/api/ApiMain.php b/includes/api/ApiMain.php
index 7ea691074831..58810a91b89e 100644
--- a/includes/api/ApiMain.php
+++ b/includes/api/ApiMain.php
@@ -1907,10 +1907,20 @@ class ApiMain extends ApiBase {
$this->dieWithErrorOrDebug( [ 'apierror-mustbeposted', $this->mAction ] );
}
- if ( $request->wasPosted() && !$request->getHeader( 'Content-Type' ) ) {
- $this->addDeprecation(
- 'apiwarn-deprecation-post-without-content-type', 'post-without-content-type'
- );
+ if ( $request->wasPosted() ) {
+ if ( !$request->getHeader( 'Content-Type' ) ) {
+ $this->addDeprecation(
+ 'apiwarn-deprecation-post-without-content-type', 'post-without-content-type'
+ );
+ }
+ $contentLength = $request->getHeader( 'Content-Length' );
+ $maxPostSize = wfShorthandToInteger( ini_get( 'post_max_size' ), 0 );
+ if ( $maxPostSize && $contentLength > $maxPostSize ) {
+ $this->dieWithError(
+ [ 'apierror-http-contenttoolarge', Message::sizeParam( $maxPostSize ) ],
+ null, null, 413
+ );
+ }
}
// See if custom printer is used