TYPO3 API  SVNRelease
class.t3lib_utility_http.php
Go to the documentation of this file.
00001 <?php
00002 /***************************************************************
00003  *  Copyright notice
00004  *
00005  *  (c) 2009-2011 Ingo Renner <ingo@typo3.org>
00006  *  All rights reserved
00007  *
00008  *  This script is part of the TYPO3 project. The TYPO3 project is
00009  *  free software; you can redistribute it and/or modify
00010  *  it under the terms of the GNU General Public License as published by
00011  *  the Free Software Foundation; either version 2 of the License, or
00012  *  (at your option) any later version.
00013  *
00014  *  The GNU General Public License can be found at
00015  *  http://www.gnu.org/copyleft/gpl.html.
00016  *
00017  *  This script is distributed in the hope that it will be useful,
00018  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00019  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020  *  GNU General Public License for more details.
00021  *
00022  *  This copyright notice MUST APPEAR in all copies of the script!
00023  ***************************************************************/
00024 
00025 
00026 /**
00027  * HTTP Utility class
00028  *
00029  * @author  Ingo Renner <ingo@typo3.org>
00030  * @package TYPO3
00031  * @subpackage t3lib
00032  */
00033 class t3lib_utility_Http {
00034 
00035         // HTTP Headers, see http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html for Details
00036     const HTTP_STATUS_100 = 'HTTP/1.1 100 Continue';
00037     const HTTP_STATUS_101 = 'HTTP/1.1 101 Switching Protocols';
00038 
00039     const HTTP_STATUS_200 = 'HTTP/1.1 200 OK';
00040     const HTTP_STATUS_201 = 'HTTP/1.1 201 Created';
00041     const HTTP_STATUS_202 = 'HTTP/1.1 202 Accepted';
00042     const HTTP_STATUS_203 = 'HTTP/1.1 203 Non-Authoritative Information';
00043     const HTTP_STATUS_204 = 'HTTP/1.1 204 No Content';
00044     const HTTP_STATUS_205 = 'HTTP/1.1 205 Reset Content';
00045     const HTTP_STATUS_206 = 'HTTP/1.1 206 Partial Content';
00046 
00047     const HTTP_STATUS_300 = 'HTTP/1.1 300 Multiple Choices';
00048     const HTTP_STATUS_301 = 'HTTP/1.1 301 Moved Permanently';
00049     const HTTP_STATUS_302 = 'HTTP/1.1 302 Found';
00050     const HTTP_STATUS_303 = 'HTTP/1.1 303 See Other';
00051     const HTTP_STATUS_304 = 'HTTP/1.1 304 Not Modified';
00052     const HTTP_STATUS_305 = 'HTTP/1.1 305 Use Proxy';
00053     const HTTP_STATUS_307 = 'HTTP/1.1 307 Temporary Redirect';
00054 
00055     const HTTP_STATUS_400 = 'HTTP/1.1 400 Bad Request';
00056     const HTTP_STATUS_401 = 'HTTP/1.1 401 Unauthorized';
00057     const HTTP_STATUS_402 = 'HTTP/1.1 402 Payment Required';
00058     const HTTP_STATUS_403 = 'HTTP/1.1 403 Forbidden';
00059     const HTTP_STATUS_404 = 'HTTP/1.1 404 Not Found';
00060     const HTTP_STATUS_405 = 'HTTP/1.1 405 Method Not Allowed';
00061     const HTTP_STATUS_406 = 'HTTP/1.1 406 Not Acceptable';
00062     const HTTP_STATUS_407 = 'HTTP/1.1 407 Proxy Authentication Required';
00063     const HTTP_STATUS_408 = 'HTTP/1.1 408 Request Timeout';
00064     const HTTP_STATUS_409 = 'HTTP/1.1 409 Conflict';
00065     const HTTP_STATUS_410 = 'HTTP/1.1 410 Gone';
00066     const HTTP_STATUS_411 = 'HTTP/1.1 411 Length Required';
00067     const HTTP_STATUS_412 = 'HTTP/1.1 412 Precondition Failed';
00068     const HTTP_STATUS_413 = 'HTTP/1.1 413 Request Entity Too Large';
00069     const HTTP_STATUS_414 = 'HTTP/1.1 414 Request-URI Too Long';
00070     const HTTP_STATUS_415 = 'HTTP/1.1 415 Unsupported Media Type';
00071     const HTTP_STATUS_416 = 'HTTP/1.1 416 Requested Range Not Satisfiable';
00072     const HTTP_STATUS_417 = 'HTTP/1.1 417 Expectation Failed';
00073 
00074     const HTTP_STATUS_500 = 'HTTP/1.1 500 Internal Server Error';
00075     const HTTP_STATUS_501 = 'HTTP/1.1 501 Not Implemented';
00076     const HTTP_STATUS_502 = 'HTTP/1.1 502 Bad Gateway';
00077     const HTTP_STATUS_503 = 'HTTP/1.1 503 Service Unavailable';
00078     const HTTP_STATUS_504 = 'HTTP/1.1 504 Gateway Timeout';
00079     const HTTP_STATUS_505 = 'HTTP/1.1 505 Version Not Supported';
00080 
00081         // URL Schemes
00082     const SCHEME_HTTP = 1;
00083     const SCHEME_HTTPS = 2;
00084 
00085     /**
00086      * Sends a redirect header response and exits. Additionaly the URL is
00087      * checked and if needed corrected to match the format required for a
00088      * Location redirect header. By default the HTTP status code sent is
00089      * a 'HTTP/1.1 303 See Other'.
00090      *
00091      * @param   string  The target URL to redirect to
00092      * @param   string  An optional HTTP status header. Default is 'HTTP/1.1 303 See Other'
00093      */
00094     public static function redirect($url, $httpStatus = self::HTTP_STATUS_303) {
00095         header($httpStatus);
00096         header('Location: ' . t3lib_div::locationHeaderUrl($url));
00097 
00098         exit;
00099     }
00100 }
00101 
00102 ?>