PluginProbe
WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance / 3.2.5
WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance v3.2.5
4.7.0 4.6.1 4.6.0 4.5.5 4.5.4 4.5.3 4.5.2 3.2.20 3.2.21 3.2.22 3.2.3 3.2.5 3.2.6 3.2.7 3.2.9 3.3.0 3.3.1 3.3.2 3.4.0 3.4.1 3.4.2 3.5.0 3.6.0 3.7.0 3.7.1 All 111 releases
wp-optimize / vendor / rosell-dk / htaccess-capability-tester / src / HttpResponse.php

HttpResponse.php in WP-Optimize – Cache, Compress images, Minify & Clean database to boost page speed & performance 3.2.5, at vendor/rosell-dk/htaccess-capability-tester/src/HttpResponse.php

76 lines 2.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace HtaccessCapabilityTester;
4
5 /**
6 * Class for holding properties of a HttpResponse
7 *
8 * @package HtaccessCapabilityTester
9 * @author Bjørn Rosell <[email protected]>
10 * @since Class available since 0.7
11 */
12 class HttpResponse
13 {
14
15 /* @var string the body of the response */
16 public $body;
17
18 /* @var string the status code of the response */
19 public $statusCode;
20
21 /* @var array the response headers keyed by lowercased field name */
22 public $headersMapLowerCase;
23
24 /**
25 * Constructor.
26 *
27 * @param string $body
28 * @param string $statusCode
29 * @param array $headersMap Map of headers, keyed by field name.
30 * There is only one value (string) for each key.
31 * If there are multiple values, they must be separated by comma
32 *
33 * @return void
34 */
35 public function __construct($body, $statusCode, $headersMap)
36 {
37 $this->body = $body;
38 $this->statusCode = $statusCode;
39 $this->headersMapLowerCase = array_change_key_case($headersMap, CASE_LOWER);
40 }
41
42 /**
43 * Check if the response has a header
44 *
45 * @param string $fieldName
46 * @return bool
47 */
48 public function hasHeader($fieldName)
49 {
50 $fieldName = strtolower($fieldName);
51 return (isset($this->headersMapLowerCase[$fieldName]));
52 }
53
54 /**
55 * Check if the response has a header with a given value
56 *
57 * @param string $fieldName
58 * @param string $fieldValue
59 * @return bool
60 */
61 public function hasHeaderValue($fieldName, $fieldValue)
62 {
63 $fieldName = strtolower($fieldName);
64 if (!isset($this->headersMapLowerCase[$fieldName])) {
65 return false;
66 }
67 $values = explode(',', $this->headersMapLowerCase[$fieldName]);
68 foreach ($values as $value) {
69 if (trim($value) == $fieldValue) {
70 return true;
71 }
72 }
73 return false;
74 }
75 }
76