Makes WebRequest::detectProtocolAndStdPort() take HTTP_X_FORWARDED_PROTO headers...
authorawjrichards <arichards@wikimedia.org>
Thu, 3 Jan 2013 23:45:44 +0000 (15:45 -0800)
committerawjrichards <arichards@wikimedia.org>
Thu, 3 Jan 2013 23:46:34 +0000 (15:46 -0800)
Change-Id: I4debf1460b6357962fc634f781416929bcca2d76

includes/WebRequest.php

index 8cf25bb..fc1cdb5 100644 (file)
@@ -192,7 +192,14 @@ class WebRequest {
         * @return array
         */
        public static function detectProtocolAndStdPort() {
-               return ( isset( $_SERVER['HTTPS'] ) && $_SERVER['HTTPS'] == 'on' ) ? array( 'https', 443 ) : array( 'http', 80 );
+               if ( ( isset( $_SERVER['HTTPS'] ) && $_SERVER['HTTPS'] == 'on' ) ||
+                       ( isset( $_SERVER['HTTP_X_FORWARDED_PROTO'] ) &&
+                       $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' ) ) {
+                       $arr = array( 'https', 443 );
+               } else {
+                       $arr = array( 'http', 80 );
+               }
+               return $arr;
        }
 
        /**