Make WordPress Core

Changeset 2623


Ignore:
Timestamp:
06/09/2005 12:17:43 AM (20 years ago)
Author:
matt
Message:

Better headers for CGI enviroments

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/admin.php

    r2592 r2623  
    88auth_redirect();
    99
    10 header('Expires: Wed, 11 Jan 1984 05:00:00 GMT');
    11 header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
    12 header('Cache-Control: no-cache, must-revalidate, max-age=0');
    13 header('Pragma: no-cache');
     10nocache_headers();
    1411
    1512update_category_cache();
  • trunk/wp-blog-header.php

    r2600 r2623  
    108108
    109109// Sending HTTP headers
     110@header('X-Pingback: '. get_bloginfo('pingback_url'));
    110111
    111112if ( !empty($error) && '404' == $error ) {
    112     if ( preg_match('/cgi/', php_sapi_name()) )
    113         @header('Status: 404 Not Found');
    114     else
    115         @header('HTTP/1.x 404 Not Found');
     113    status_header( 404 );
    116114 } else if ( empty($feed) ) {
    117     @header('X-Pingback: '. get_bloginfo('pingback_url'));
    118115    @header('Content-type: ' . get_option('html_type') . '; charset=' . get_option('blog_charset'));
    119116} else {
     
    126123    @header("Last-Modified: $wp_last_modified");
    127124    @header("ETag: $wp_etag");
    128     @header('X-Pingback: ' . get_bloginfo('pingback_url'));
    129125
    130126    // Support for Conditional GET
     
    142138        (($client_modified_timestamp >= $wp_modified_timestamp) && ($client_etag == $wp_etag)) :
    143139        (($client_modified_timestamp >= $wp_modified_timestamp) || ($client_etag == $wp_etag)) ) {
    144         if ( preg_match('/cgi/',php_sapi_name()) ) {
    145             header('Status: 304 Not Modified');
    146             echo "\r\n\r\n";
    147             exit;
    148         } else {
    149             if ( version_compare(phpversion(), '4.3.0', '>=') )
    150                 header('Not Modified', TRUE, 304);
    151             else
    152                 header('HTTP/1.x 304 Not Modified');
    153             exit;
    154         }
     140        status_header( 304 );
     141        exit;
    155142    }
    156143}
     
    192179        (false === strpos($_SERVER['REQUEST_URI'], '?'))) ) ) {
    193180    $wp_query->is_404 = true;
    194     if ( preg_match('/cgi/', php_sapi_name()) )
    195         @header('Status: 404 Not Found');
    196     else
    197         @header('HTTP/1.x 404 Not Found');
     181    status_header( 404 );
     182} else {
     183    status_header( 200 );
    198184}
    199185
  • trunk/wp-comments-post.php

    r2580 r2623  
    5353setcookie('comment_author_url_' . COOKIEHASH, stripslashes($comment_author_url), time() + 30000000, COOKIEPATH);
    5454
    55 header('Expires: Wed, 11 Jan 1984 05:00:00 GMT');
    56 header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
    57 header('Cache-Control: no-cache, must-revalidate, max-age=0');
    58 header('Pragma: no-cache');
     55nocache_headers();
    5956
    6057$location = (empty($_POST['redirect_to'])) ? $_SERVER["HTTP_REFERER"] : $_POST['redirect_to'];
  • trunk/wp-includes/functions.php

    r2616 r2623  
    18501850}
    18511851
     1852function status_header( $header ) {
     1853    if ( 200 == $header ) {
     1854        $text = 'OK';
     1855    } elseif ( 301 == $header ) {
     1856        $text = 'Moved Permanently';
     1857    } elseif ( 302 == $header ) {
     1858        $text = 'Moved Temporarily';
     1859    } elseif ( 304 == $header ) {
     1860        $text = 'Not Modified';
     1861    } elseif ( 404 == $header ) {
     1862        $text = 'Not Found';
     1863    } elseif ( 410 == $header ) {
     1864        $text = 'Gone';
     1865    }
     1866    if ( preg_match('/cgi/',php_sapi_name()) ) {
     1867        @header("Status: $header $text");
     1868        echo "\r\n\r\n";
     1869    } else {
     1870        if ( version_compare(phpversion(), '4.3.0', '>=') )
     1871            @header($text, TRUE, $header);
     1872        else
     1873            @header("HTTP/1.x $header $text");
     1874    }
     1875}
     1876
     1877function nocache_headers() {
     1878    @ header('Expires: Wed, 11 Jan 1984 05:00:00 GMT');
     1879    @ header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
     1880    @ header('Cache-Control: no-cache, must-revalidate, max-age=0');
     1881    @ header('Pragma: no-cache');
     1882}
     1883
    18521884?>
  • trunk/wp-includes/pluggable-functions.php

    r2607 r2623  
    107107                !wp_login($_COOKIE['wordpressuser_' . COOKIEHASH], $_COOKIE['wordpresspass_' . COOKIEHASH], true)) ||
    108108             (empty($_COOKIE['wordpressuser_' . COOKIEHASH])) ) {
    109         header('Expires: Wed, 11 Jan 1984 05:00:00 GMT');
    110         header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
    111         header('Cache-Control: no-cache, must-revalidate, max-age=0');
    112         header('Pragma: no-cache');
     109        nocache_headers();
    113110   
    114111        header('Location: ' . get_settings('siteurl') . '/wp-login.php?redirect_to=' . urlencode($_SERVER['REQUEST_URI']));
  • trunk/wp-login.php

    r2552 r2623  
    55$error = '';
    66
    7 header('Expires: Wed, 11 Jan 1984 05:00:00 GMT');
    8 header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
    9 header('Cache-Control: no-cache, must-revalidate');
    10 header('Pragma: no-cache');
     7nocache_headers();
     8
    119header('Content-Type: '.get_bloginfo('html_type').'; charset='.get_bloginfo('charset'));
    1210
     
    2523    wp_clearcookie();
    2624    do_action('wp_logout');
    27     header('Expires: Wed, 11 Jan 1984 05:00:00 GMT');
    28     header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
    29     header('Cache-Control: no-cache, must-revalidate, max-age=0');
    30     header('Pragma: no-cache');
     25    nocache_headers();
    3126    wp_redirect('wp-login.php');
    3227    exit();
Note: See TracChangeset for help on using the changeset viewer.