Make WordPress Core

Ticket #34131: 34131.2.diff

File 34131.2.diff, 2.7 KB (added by wonderboymusic, 9 years ago)
  • src/wp-includes/functions.php

     
    992992        if ( empty( $description ) )
    993993                return;
    994994
    995         $protocol = $_SERVER['SERVER_PROTOCOL'];
    996         if ( 'HTTP/1.1' != $protocol && 'HTTP/1.0' != $protocol )
    997                 $protocol = 'HTTP/1.0';
     995        $protocol = wp_get_server_protocol();
    998996        $status_header = "$protocol $code $description";
    999997        if ( function_exists( 'apply_filters' ) )
    1000998
  • src/wp-includes/load.php

     
    88 */
    99
    1010/**
     11 * Return the HTTP protocol sent by the server.
     12 *
     13 * @since 4.4.0
     14 *
     15 * @return string The HTTP protocol. Default: HTTP/1.0.
     16 */
     17function wp_get_server_protocol() {
     18        $protocol = $_SERVER['SERVER_PROTOCOL'];
     19        if ( ! in_array( $protocol, array( 'HTTP/1.1', 'HTTP/2', 'HTTP/2.0' ) ) ) {
     20                $protocol = 'HTTP/1.0';
     21        }
     22        return $protocol;
     23}
     24
     25/**
    1126 * Turn register globals off.
    1227 *
    1328 * @since 2.1.0
     
    112127        if ( version_compare( $required_php_version, $php_version, '>' ) ) {
    113128                wp_load_translations_early();
    114129
    115                 $protocol = $_SERVER['SERVER_PROTOCOL'];
    116                 if ( 'HTTP/1.1' !== $protocol && 'HTTP/1.0' !== $protocol ) {
    117                         $protocol = 'HTTP/1.0';
    118                 }
     130                $protocol = wp_get_server_protocol();
    119131                header( sprintf( '%s 500 Internal Server Error', $protocol ), true, 500 );
    120132                header( 'Content-Type: text/html; charset=utf-8' );
    121133                die( sprintf( __( 'Your server is running PHP version %1$s but WordPress %2$s requires at least %3$s.' ), $php_version, $wp_version, $required_php_version ) );
     
    124136        if ( ! extension_loaded( 'mysql' ) && ! extension_loaded( 'mysqli' ) && ! file_exists( WP_CONTENT_DIR . '/db.php' ) ) {
    125137                wp_load_translations_early();
    126138
    127                 $protocol = $_SERVER['SERVER_PROTOCOL'];
    128                 if ( 'HTTP/1.1' !== $protocol && 'HTTP/1.0' !== $protocol ) {
    129                         $protocol = 'HTTP/1.0';
    130                 }
     139                $protocol = wp_get_server_protocol();
    131140                header( sprintf( '%s 500 Internal Server Error', $protocol ), true, 500 );
    132141                header( 'Content-Type: text/html; charset=utf-8' );
    133142                die( __( 'Your PHP installation appears to be missing the MySQL extension which is required by WordPress.' ) );
     
    182191
    183192        wp_load_translations_early();
    184193
    185         $protocol = $_SERVER["SERVER_PROTOCOL"];
    186         if ( 'HTTP/1.1' != $protocol && 'HTTP/1.0' != $protocol )
    187                 $protocol = 'HTTP/1.0';
     194        $protocol = wp_get_server_protocol();
    188195        header( "$protocol 503 Service Unavailable", true, 503 );
    189196        header( 'Content-Type: text/html; charset=utf-8' );
    190197        header( 'Retry-After: 600' );