TYPO3 CMS  TYPO3_6-2
HttpUtility.php
Go to the documentation of this file.
1 <?php
2 namespace TYPO3\CMS\Core\Utility;
3 
21 class HttpUtility {
22 
23  // HTTP Headers, see http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html for Details
24  const HTTP_STATUS_100 = 'HTTP/1.1 100 Continue';
25  const HTTP_STATUS_101 = 'HTTP/1.1 101 Switching Protocols';
26  const HTTP_STATUS_200 = 'HTTP/1.1 200 OK';
27  const HTTP_STATUS_201 = 'HTTP/1.1 201 Created';
28  const HTTP_STATUS_202 = 'HTTP/1.1 202 Accepted';
29  const HTTP_STATUS_203 = 'HTTP/1.1 203 Non-Authoritative Information';
30  const HTTP_STATUS_204 = 'HTTP/1.1 204 No Content';
31  const HTTP_STATUS_205 = 'HTTP/1.1 205 Reset Content';
32  const HTTP_STATUS_206 = 'HTTP/1.1 206 Partial Content';
33  const HTTP_STATUS_300 = 'HTTP/1.1 300 Multiple Choices';
34  const HTTP_STATUS_301 = 'HTTP/1.1 301 Moved Permanently';
35  const HTTP_STATUS_302 = 'HTTP/1.1 302 Found';
36  const HTTP_STATUS_303 = 'HTTP/1.1 303 See Other';
37  const HTTP_STATUS_304 = 'HTTP/1.1 304 Not Modified';
38  const HTTP_STATUS_305 = 'HTTP/1.1 305 Use Proxy';
39  const HTTP_STATUS_307 = 'HTTP/1.1 307 Temporary Redirect';
40  const HTTP_STATUS_400 = 'HTTP/1.1 400 Bad Request';
41  const HTTP_STATUS_401 = 'HTTP/1.1 401 Unauthorized';
42  const HTTP_STATUS_402 = 'HTTP/1.1 402 Payment Required';
43  const HTTP_STATUS_403 = 'HTTP/1.1 403 Forbidden';
44  const HTTP_STATUS_404 = 'HTTP/1.1 404 Not Found';
45  const HTTP_STATUS_405 = 'HTTP/1.1 405 Method Not Allowed';
46  const HTTP_STATUS_406 = 'HTTP/1.1 406 Not Acceptable';
47  const HTTP_STATUS_407 = 'HTTP/1.1 407 Proxy Authentication Required';
48  const HTTP_STATUS_408 = 'HTTP/1.1 408 Request Timeout';
49  const HTTP_STATUS_409 = 'HTTP/1.1 409 Conflict';
50  const HTTP_STATUS_410 = 'HTTP/1.1 410 Gone';
51  const HTTP_STATUS_411 = 'HTTP/1.1 411 Length Required';
52  const HTTP_STATUS_412 = 'HTTP/1.1 412 Precondition Failed';
53  const HTTP_STATUS_413 = 'HTTP/1.1 413 Request Entity Too Large';
54  const HTTP_STATUS_414 = 'HTTP/1.1 414 Request-URI Too Long';
55  const HTTP_STATUS_415 = 'HTTP/1.1 415 Unsupported Media Type';
56  const HTTP_STATUS_416 = 'HTTP/1.1 416 Requested Range Not Satisfiable';
57  const HTTP_STATUS_417 = 'HTTP/1.1 417 Expectation Failed';
58  const HTTP_STATUS_500 = 'HTTP/1.1 500 Internal Server Error';
59  const HTTP_STATUS_501 = 'HTTP/1.1 501 Not Implemented';
60  const HTTP_STATUS_502 = 'HTTP/1.1 502 Bad Gateway';
61  const HTTP_STATUS_503 = 'HTTP/1.1 503 Service Unavailable';
62  const HTTP_STATUS_504 = 'HTTP/1.1 504 Gateway Timeout';
63  const HTTP_STATUS_505 = 'HTTP/1.1 505 Version Not Supported';
64  // URL Schemes
65  const SCHEME_HTTP = 1;
66  const SCHEME_HTTPS = 2;
76  static public function redirect($url, $httpStatus = self::HTTP_STATUS_303) {
77  self::setResponseCode($httpStatus);
78  header('Location: ' . \TYPO3\CMS\Core\Utility\GeneralUtility::locationHeaderUrl($url));
79  die;
80  }
81 
88  static public function setResponseCode($httpStatus = self::HTTP_STATUS_303) {
89  header($httpStatus);
90  }
91 
98  static public function setResponseCodeAndExit($httpStatus = self::HTTP_STATUS_303) {
99  self::setResponseCode($httpStatus);
100  die;
101  }
102 
110  static public function buildUrl(array $urlParts) {
111  return (isset($urlParts['scheme']) ? $urlParts['scheme'] . '://' : '') .
112  (isset($urlParts['user']) ? $urlParts['user'] .
113  (isset($urlParts['pass']) ? ':' . $urlParts['pass'] : '') . '@' : '') .
114  (isset($urlParts['host']) ? $urlParts['host'] : '') .
115  (isset($urlParts['port']) ? ':' . $urlParts['port'] : '') .
116  (isset($urlParts['path']) ? $urlParts['path'] : '') .
117  (isset($urlParts['query']) ? '?' . $urlParts['query'] : '') .
118  (isset($urlParts['fragment']) ? '#' . $urlParts['fragment'] : '');
119  }
120 
121 }
die
Definition: index.php:6
static setResponseCode($httpStatus=self::HTTP_STATUS_303)
Definition: HttpUtility.php:88
static buildUrl(array $urlParts)
static redirect($url, $httpStatus=self::HTTP_STATUS_303)
Definition: HttpUtility.php:76
static setResponseCodeAndExit($httpStatus=self::HTTP_STATUS_303)
Definition: HttpUtility.php:98