jenkins-bot has submitted this change and it was merged.

Change subject: Have API pass through 'X-Parsoid-Performance' header from 
Parsoid
......................................................................


Have API pass through 'X-Parsoid-Performance' header from Parsoid

Change I1d7fd94f2 to Parsoid adds a custom header on Parsoid HTTP responses,
'X-Parsoid-Performance', which contains data about how long it took Parsoid to
handle the request. This patch makes the API pass through the header from
Parsoid to the client, where it will be logged as an event (along with
additional datapoints that are only available on the client). When the request
is fulfilled entirely by Varnish, the XPP value is replaced with
'backend-varnish-hit: true'.

Change-Id: I8085fdba35c860eaaa4df020d06d1d45d4ea5813
---
M ApiVisualEditor.php
1 file changed, 13 insertions(+), 0 deletions(-)

Approvals:
  Catrope: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/ApiVisualEditor.php b/ApiVisualEditor.php
index 2b0f599..52d4beb 100644
--- a/ApiVisualEditor.php
+++ b/ApiVisualEditor.php
@@ -49,6 +49,19 @@
 
                        if ( $status->isOK() ) {
                                $content = $req->getContent();
+                               // Pass thru performance data from Parsoid to 
the client, unless the response was
+                               // served directly from Varnish, in  which case 
discard the value of the XPP header
+                               // and use it to declare the cache hit instead.
+                               $xCache = $req->getResponseHeader( 'X-Cache' );
+                               if ( is_string( $xCache ) && strpos( $xCache, 
'hit' ) !== false ) {
+                                       $xpp = 'backend-varnish-hit: true';
+                               } else {
+                                       $xpp = $req->getResponseHeader( 
'X-Parsoid-Performance' );
+                               }
+                               if ( $xpp !== null ) {
+                                       $resp = $this->getRequest()->response();
+                                       $resp->header( 'X-Parsoid-Performance: 
' . $xpp );
+                               }
                        } elseif ( $status->isGood() ) {
                                $this->dieUsage( $req->getContent(), 
'parsoidserver-http-'.$req->getStatus() );
                        } elseif ( $errors = $status->getErrorsByType( 'error' 
) ) {

-- 
To view, visit https://gerrit.wikimedia.org/r/87532
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I8085fdba35c860eaaa4df020d06d1d45d4ea5813
Gerrit-PatchSet: 5
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Ori.livneh <[email protected]>
Gerrit-Reviewer: Catrope <[email protected]>
Gerrit-Reviewer: Esanders <[email protected]>
Gerrit-Reviewer: GWicke <[email protected]>
Gerrit-Reviewer: jenkins-bot

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to