Add Vary: X-Forwarded-Proto for https redirects
authorcsteipp <csteipp@wikimedia.org>
Mon, 30 Sep 2013 18:04:45 +0000 (11:04 -0700)
committercsteipp <csteipp@wikimedia.org>
Mon, 30 Sep 2013 18:04:45 +0000 (11:04 -0700)
From mark's comments on https://gerrit.wikimedia.org/r/#/c/86268/, we
should be setting Vary: X-Forwarded-Proto when the response varies on
the protocol, which is the case for redirects from http->https.

Change-Id: Ie6dc9da4e804199b99e3a7abbea7775a181801a0

includes/Wiki.php
includes/specials/SpecialUserlogin.php

index 0683d7c..b3bcf33 100644 (file)
@@ -539,6 +539,8 @@ class MediaWiki {
                        $title = Title::newFromText( NS_MAIN, 'REDIR' );
                        $this->context->setTitle( $title );
                        $output = $this->context->getOutput();
+                       // Since we only do this redir to change proto, always send a vary header
+                       $output->addVaryHeader( 'X-Forwarded-Proto' );
                        $output->redirect( $redirUrl );
                        $output->output();
                        wfProfileOut( __METHOD__ );
index a68efc4..9429f10 100644 (file)
@@ -178,6 +178,8 @@ class LoginForm extends SpecialPage {
                        if ( $wgSecureLogin && wfCanIPUseHTTPS( $this->getRequest()->getIP() ) ) {
                                $url = wfAppendQuery( $url, 'fromhttp=1' );
                                $this->getOutput()->redirect( $url );
+                               // Since we only do this redir to change proto, always vary
+                               $this->getOutput()->addVaryHeader( 'X-Forwarded-Proto' );
                                return;
                        } else {
                                // A wiki without HTTPS login support should set $wgServer to