Chad has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/308283

Change subject: HttpStatus: Support HTTP/2.0
......................................................................

HttpStatus: Support HTTP/2.0

While we're at it, add some comments and restructure a bit so it's
more future-proof as well for when 2.1 or 3.0 come along 10 years
from now :)

Change-Id: If7bf350791f8bbcdb1988ffa641dc2f57d7162ae
---
M includes/libs/HttpStatus.php
1 file changed, 16 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/83/308283/1

diff --git a/includes/libs/HttpStatus.php b/includes/libs/HttpStatus.php
index 72fc333..0d1aeff 100644
--- a/includes/libs/HttpStatus.php
+++ b/includes/libs/HttpStatus.php
@@ -102,10 +102,22 @@
                }
 
                if ( $version === null ) {
-                       $version = isset( $_SERVER['SERVER_PROTOCOL'] ) &&
-                               $_SERVER['SERVER_PROTOCOL'] === 'HTTP/1.0' ?
-                                       '1.0' :
-                                       '1.1';
+                       // If we don't have a protocol set, assume http/1.1, 
that seems safe
+                       $protocol = isset( $_SERVER['SERVER_PROTOCOL'] ) ?
+                               $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.1';
+
+                       // Extract the version number itself
+                       switch( $protocol ) {
+                               case 'HTTP/1.0':
+                                       $version = '1.0';
+                                       break;
+                               case 'HTTP/2.0':
+                                       $version = '2.0';
+                                       break;
+                               case 'HTTP/1.1':
+                               default:
+                                       $version = '1.1';
+                       }
                }
 
                header( "HTTP/$version $code $message" );

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: If7bf350791f8bbcdb1988ffa641dc2f57d7162ae
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Chad <ch...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to