From: Ilmari Karonen Date: Wed, 1 Oct 2008 21:38:13 +0000 (+0000) Subject: Make the API maxlag check send the same "Retry-After" and "X-Database-Lag" headers... X-Git-Tag: 1.31.0-rc.0~44965 X-Git-Url: https://git.cyclocoop.org/%242?a=commitdiff_plain;h=69c1dd9e7ee8d1d7d24135d99e0135c8277b9194;p=lhc%2Fweb%2Fwiklou.git Make the API maxlag check send the same "Retry-After" and "X-Database-Lag" headers as wfMaxlagError() does. The HTTP status code is still different, I can see arguments for having it either way. --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index af01ec4ad0..6e4cadf649 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -142,6 +142,8 @@ The following extensions are migrated into MediaWiki 1.14: * Improved upload file type detection for OpenDocument formats * Added the ability to set the target attribute on external links with $wgExternalLinkTarget +* api.php now sends "Retry-After" and "X-Database-Lag" HTTP headers if the maxlag + check fails, just like index.php does === Bug fixes in 1.14 === diff --git a/includes/api/ApiMain.php b/includes/api/ApiMain.php index a1e381557f..b339f0f049 100644 --- a/includes/api/ApiMain.php +++ b/includes/api/ApiMain.php @@ -392,6 +392,9 @@ class ApiMain extends ApiBase { $maxLag = $params['maxlag']; list( $host, $lag ) = wfGetLB()->getMaxLag(); if ( $lag > $maxLag ) { + header( 'Retry-After: ' . max( intval( $maxLag ), 5 ) ); + header( 'X-Database-Lag: ' . intval( $lag ) ); + // XXX: should we return a 503 HTTP error code like wfMaxlagError() does? if( $wgShowHostnames ) { ApiBase :: dieUsage( "Waiting for $host: $lag seconds lagged", 'maxlag' ); } else {