File tree Expand file tree Collapse file tree 3 files changed +54
-4
lines changed Expand file tree Collapse file tree 3 files changed +54
-4
lines changed Original file line number Diff line number Diff line change @@ -103,9 +103,7 @@ public function offsetGet($offset)
103103 */
104104 public function offsetSet ($ offset , $ value )
105105 {
106- if ($ this ->offsetExists ($ offset )) {
107- $ this ->_fields [$ offset ] = $ value ;
108- }
106+ $ this ->_fields [$ offset ] = $ value ;
109107 }
110108
111109 /**
Original file line number Diff line number Diff line change @@ -56,6 +56,16 @@ class Request
5656 */
5757 private $ _body ;
5858
59+ /**
60+ * @var RequestData
61+ */
62+ private $ _cookies ;
63+
64+ /**
65+ * @var RequestHeader
66+ */
67+ private $ _header ;
68+
5969 /**
6070 * @var RequestUri
6171 */
@@ -67,6 +77,21 @@ class Request
6777 private function __construct ()
6878 {
6979 $ this ->uri = new RequestUri ();
80+
81+ $ this ->_header = new RequestHeader ();
82+
83+ foreach ($ _SERVER as $ key => $ value ) {
84+ if (strpos ($ key , "HTTP_ " , 0 ) === 0 ) {
85+ $ parts = explode ("_ " , $ key );
86+ array_shift ($ parts );
87+
88+ $ headerName = implode ("- " , array_map (function ($ name ) {
89+ return ucfirst (strtolower ($ name ));
90+ }, $ parts ));
91+
92+ $ this ->_header [$ headerName ] = $ value ;
93+ }
94+ }
7095 }
7196
7297 /**
@@ -129,6 +154,30 @@ public function setBody(RequestData $body): void
129154 $ this ->_body = $ body ;
130155 }
131156
157+ /**
158+ * @return RequestData
159+ */
160+ public function getCookies (): RequestData
161+ {
162+ return $ this ->_cookies ;
163+ }
164+
165+ /**
166+ * @param RequestData $cookies
167+ */
168+ public function setCookies (RequestData $ cookies ): void
169+ {
170+ $ this ->_cookies = $ cookies ;
171+ }
172+
173+ /**
174+ * @return RequestHeader
175+ */
176+ public function getHeader (): RequestHeader
177+ {
178+ return $ this ->_header ;
179+ }
180+
132181 /**
133182 * Checks if the current request is from Ajax.
134183 *
Original file line number Diff line number Diff line change @@ -101,14 +101,17 @@ private function _detectUri()
101101 if (isset ($ parts [1 ]) && $ config ->isQueryStringEnabled ()) {
102102 $ _SERVER ['QUERY_STRING ' ] = $ parts [1 ];
103103 parse_str ($ _SERVER ['QUERY_STRING ' ], $ _GET );
104- $ this ->_request ->setParams (new RequestData ($ _GET ));
105104 } else {
106105 $ _SERVER ['QUERY_STRING ' ] = '' ;
107106 $ _GET = array ();
108107 }
109108
109+ $ this ->_request ->setParams (new RequestData ($ _GET ));
110+
110111 $ this ->_request ->setBody (new RequestData ($ _POST ));
111112
113+ $ this ->_request ->setCookies (new RequestData ($ _COOKIE ));
114+
112115 if ($ uri == '/ ' || empty ($ uri )) {
113116 $ this ->_request ->uri ->setUri ('/ ' );
114117 return ;
You can’t perform that action at this time.
0 commit comments