Fixed bug #14681: Use self:: for static method calls with classname:: within the...
[Packages/TYPO3.CMS.git] / t3lib / utility / class.t3lib_utility_http.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 2009-2010 Ingo Renner <ingo@typo3.org>
6 * All rights reserved
7 *
8 * This script is part of the TYPO3 project. The TYPO3 project is
9 * free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
16 *
17 * This script is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * This copyright notice MUST APPEAR in all copies of the script!
23 ***************************************************************/
24
25
26 /**
27 * HTTP Utility class
28 *
29 * @author Ingo Renner <ingo@typo3.org>
30 * @package TYPO3
31 * @subpackage t3lib
32 */
33 class t3lib_utility_Http {
34
35 // HTTP Headers, see http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html for Details
36 const HTTP_STATUS_100 = 'HTTP/1.1 100 Continue';
37 const HTTP_STATUS_101 = 'HTTP/1.1 101 Switching Protocols';
38
39 const HTTP_STATUS_200 = 'HTTP/1.1 200 OK';
40 const HTTP_STATUS_201 = 'HTTP/1.1 201 Created';
41 const HTTP_STATUS_202 = 'HTTP/1.1 202 Accepted';
42 const HTTP_STATUS_203 = 'HTTP/1.1 203 Non-Authoritative Information';
43 const HTTP_STATUS_204 = 'HTTP/1.1 204 No Content';
44 const HTTP_STATUS_205 = 'HTTP/1.1 205 Reset Content';
45 const HTTP_STATUS_206 = 'HTTP/1.1 206 Partial Content';
46
47 const HTTP_STATUS_300 = 'HTTP/1.1 300 Multiple Choices';
48 const HTTP_STATUS_301 = 'HTTP/1.1 301 Moved Permanently';
49 const HTTP_STATUS_302 = 'HTTP/1.1 302 Found';
50 const HTTP_STATUS_303 = 'HTTP/1.1 303 See Other';
51 const HTTP_STATUS_304 = 'HTTP/1.1 304 Not Modified';
52 const HTTP_STATUS_305 = 'HTTP/1.1 305 Use Proxy';
53 const HTTP_STATUS_307 = 'HTTP/1.1 307 Temporary Redirect';
54
55 const HTTP_STATUS_400 = 'HTTP/1.1 400 Bad Request';
56 const HTTP_STATUS_401 = 'HTTP/1.1 401 Unauthorized';
57 const HTTP_STATUS_402 = 'HTTP/1.1 402 Payment Required';
58 const HTTP_STATUS_403 = 'HTTP/1.1 403 Forbidden';
59 const HTTP_STATUS_404 = 'HTTP/1.1 404 Not Found';
60 const HTTP_STATUS_405 = 'HTTP/1.1 405 Method Not Allowed';
61 const HTTP_STATUS_406 = 'HTTP/1.1 406 Not Acceptable';
62 const HTTP_STATUS_407 = 'HTTP/1.1 407 Proxy Authentication Required';
63 const HTTP_STATUS_408 = 'HTTP/1.1 408 Request Timeout';
64 const HTTP_STATUS_409 = 'HTTP/1.1 409 Conflict';
65 const HTTP_STATUS_410 = 'HTTP/1.1 410 Gone';
66 const HTTP_STATUS_411 = 'HTTP/1.1 411 Length Required';
67 const HTTP_STATUS_412 = 'HTTP/1.1 412 Precondition Failed';
68 const HTTP_STATUS_413 = 'HTTP/1.1 413 Request Entity Too Large';
69 const HTTP_STATUS_414 = 'HTTP/1.1 414 Request-URI Too Long';
70 const HTTP_STATUS_415 = 'HTTP/1.1 415 Unsupported Media Type';
71 const HTTP_STATUS_416 = 'HTTP/1.1 416 Requested Range Not Satisfiable';
72 const HTTP_STATUS_417 = 'HTTP/1.1 417 Expectation Failed';
73
74 const HTTP_STATUS_500 = 'HTTP/1.1 500 Internal Server Error';
75 const HTTP_STATUS_501 = 'HTTP/1.1 501 Not Implemented';
76 const HTTP_STATUS_502 = 'HTTP/1.1 502 Bad Gateway';
77 const HTTP_STATUS_503 = 'HTTP/1.1 503 Service Unavailable';
78 const HTTP_STATUS_504 = 'HTTP/1.1 504 Gateway Timeout';
79 const HTTP_STATUS_505 = 'HTTP/1.1 505 Version Not Supported';
80
81 /**
82 * Sends a redirect header response and exits. Additionaly the URL is
83 * checked and if needed corrected to match the format required for a
84 * Location redirect header. By default the HTTP status code sent is
85 * a 'HTTP/1.1 303 See Other'.
86 *
87 * @param string The target URL to redirect to
88 * @param string An optional HTTP status header. Default is 'HTTP/1.1 303 See Other'
89 */
90 public static function redirect($url, $httpStatus = self::HTTP_STATUS_303) {
91 header($httpStatus);
92 header('Location: ' . t3lib_div::locationHeaderUrl($url));
93
94 exit;
95 }
96 }
97
98
99 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/utility/class.t3lib_utility_http.php']) {
100 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/utility/class.t3lib_utility_http.php']);
101 }
102
103 ?>