Make the API maxlag check send the same "Retry-After" and "X-Database-Lag" headers...
authorIlmari Karonen <vyznev@users.mediawiki.org>
Wed, 1 Oct 2008 21:38:13 +0000 (21:38 +0000)
committerIlmari Karonen <vyznev@users.mediawiki.org>
Wed, 1 Oct 2008 21:38:13 +0000 (21:38 +0000)
The HTTP status code is still different, I can see arguments for having it either way.

RELEASE-NOTES
includes/api/ApiMain.php

index af01ec4..6e4cadf 100644 (file)
@@ -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 ===
index a1e3815..b339f0f 100644 (file)
@@ -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 {