Ignore:
Timestamp:
2011/01/04 20:06:08 (13 years ago)
Author:
Seasoft
Message:

#887(LC_Page#sendHttpStatus を SC_Response へ移植)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/version-2_5-dev/data/class/pages/LC_Page.php

    r19805 r19817  
    471471        return sha1(uniqid(rand(), true)); 
    472472    } 
    473      
    474     /** 
    475      * HTTPステータスコードを送出する。 
    476      * 
    477      * @param integer $code HTTPステータスコード 
    478      * @return void 
    479      * @author Seasoft (新規作成) 
    480      * @see Moony_Action::status() (オリジナル) 
    481      * @link http://moony.googlecode.com/ (オリジナル) 
    482      * @author YAMAOKA Hiroyuki (オリジナル) 
    483      * @copyright 2005-2008 YAMAOKA Hiroyuki (オリジナル) 
    484      * @license http://opensource.org/licenses/bsd-license.php New BSD License (オリジナル) 
    485      * @link http://ja.wikipedia.org/wiki/HTTP%E3%82%B9%E3%83%86%E3%83%BC%E3%82%BF%E3%82%B9%E3%82%B3%E3%83%BC%E3%83%89 (邦訳) 
    486      * @license http://www.gnu.org/licenses/fdl.html GFDL (邦訳) 
    487      */ 
    488     function sendHttpStatus($code) { 
    489         $protocol = $_SERVER['SERVER_PROTOCOL']; 
    490         $httpVersion = (strpos($protocol, '1.1') !== false) ? '1.1' : '1.0'; 
    491         $messages = array( 
    492             // Informational 1xx                        // 【情報】 
    493             100 => 'Continue',                          // 継続 
    494             101 => 'Switching Protocols',               // プロトコル切替え 
    495             // Success 2xx                              // 【成功】 
    496             200 => 'OK',                                // OK 
    497             201 => 'Created',                           // 作成 
    498             202 => 'Accepted',                          // 受理 
    499             203 => 'Non-Authoritative Information',     // 信頼できない情報 
    500             204 => 'No Content',                        // 内容なし 
    501             205 => 'Reset Content',                     // 内容のリセット 
    502             206 => 'Partial Content',                   // 部分的内容 
    503             // Redirection 3xx                          // 【リダイレクション】 
    504             300 => 'Multiple Choices',                  // 複数の選択 
    505             301 => 'Moved Permanently',                 // 恒久的に移動した 
    506             302 => 'Found',  // 1.1                     // 発見した (リクエストしたリソースは一時的に移動されているときに返される) 
    507             303 => 'See Other',                         // 他を参照せよ 
    508             304 => 'Not Modified',                      // 未更新 
    509             305 => 'Use Proxy',                         // プロキシを使用せよ 
    510             // 306 is no longer used but still reserved // 将来のために予約されている 
    511             307 => 'Temporary Redirect',                // 一時的リダイレクト 
    512             // Client Error 4xx                         // 【クライアントエラー】 
    513             400 => 'Bad Request',                       // リクエストが不正である 
    514             401 => 'Unauthorized',                      // 認証が必要である 
    515             402 => 'Payment Required',                  // 支払いが必要である 
    516             403 => 'Forbidden',                         // 禁止されている 
    517             404 => 'Not Found',                         // 未検出 
    518             405 => 'Method Not Allowed',                // 許可されていないメソッド 
    519             406 => 'Not Acceptable',                    // 受理できない 
    520             407 => 'Proxy Authentication Required',     // プロキシ認証が必要である 
    521             408 => 'Request Timeout',                   // リクエストタイムアウト 
    522             409 => 'Conflict',                          // 矛盾 
    523             410 => 'Gone',                              // 消滅した 
    524             411 => 'Length Required',                   // 長さが必要 
    525             412 => 'Precondition Failed',               // 前提条件で失敗した 
    526             413 => 'Request Entity Too Large',          // リクエストエンティティが大きすぎる 
    527             414 => 'Request-URI Too Long',              // リクエストURIが大きすぎる 
    528             415 => 'Unsupported Media Type',            // サポートしていないメディアタイプ 
    529             416 => 'Requested Range Not Satisfiable',   // リクエストしたレンジは範囲外にある 
    530             417 => 'Expectation Failed',                // 期待するヘッダに失敗 
    531             // Server Error 5xx                         // 【サーバエラー】 
    532             500 => 'Internal Server Error',             // サーバ内部エラー 
    533             501 => 'Not Implemented',                   // 実装されていない 
    534             502 => 'Bad Gateway',                       // 不正なゲートウェイ 
    535             503 => 'Service Unavailable',               // サービス利用不可 
    536             504 => 'Gateway Timeout',                   // ゲートウェイタイムアウト 
    537             505 => 'HTTP Version Not Supported',        // サポートしていないHTTPバージョン 
    538             509 => 'Bandwidth Limit Exceeded'           // 帯域幅制限超過 
    539         ); 
    540         if (isset($messages[$code])) { 
    541             if ($httpVersion !== '1.1') { 
    542                 // HTTP/1.0 
    543                 $messages[302] = 'Moved Temporarily'; 
    544             } 
    545             header("HTTP/{$httpVersion} {$code} {$messages[$code]}"); 
    546             header("Status: {$code} {$messages[$code]}", true, $code); 
    547         } 
    548     } 
    549473} 
    550474?> 
Note: See TracChangeset for help on using the changeset viewer.