ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilWACDummyHeader.php
Go to the documentation of this file.
1<?php
2require_once('./Services/WebAccessChecker/interfaces/interface.ilWACHeaderInterface.php');
3
10
14 protected static $sent_headers = array();
18 protected static $status_code = 0;
19
20
26 public function sendHeader($string, $replace = true, $http_response_code = null) {
27 preg_match("/(?P<key>.*):(?P<value>.*)/um", $string, $matches);
28
29 $replaced = false;
30 if ($replace) {
31 foreach (self::$sent_headers as $i => $sent_header) {
32 preg_match("/(?P<key>.*):(?P<value>.*)/um", $sent_header, $m);
33 if ($m['key'] == $matches['key']) {
34 $replaced = true;
35 self::$sent_headers[$i] = $string;
36 break;
37 }
38 }
39 }
40 if (!$replaced || $replace) {
41 self::$sent_headers[] = $string;
42 }
43
44 if ($http_response_code) {
45 $this->sendStatusCode($http_response_code);
46 }
47 }
48
49
53 public function sendStatusCode($name) {
54 self::$status_code = $name;
55 }
56
57
62 public function headerExists($name) {
63 return in_array($name, self::$sent_headers);
64 }
65
66
70 public function getSentHeaders() {
72 }
73
74
75 public static function clear() {
76 self::$sent_headers = array();
77 self::$status_code = 0;
78 }
79}
An exception for terminatinating execution or to throw for unit testing.
Class ilWACDummyHeader.
sendHeader($string, $replace=true, $http_response_code=null)
Class ilWACHeaderInterface.