You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: user_guide_src/source/incoming/incomingrequest.rst
+10-9Lines changed: 10 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,6 @@
1
+
#####################
1
2
IncomingRequest Class
2
-
*********************
3
+
#####################
3
4
4
5
The IncomingRequest class provides an object-oriented representation of an HTTP request from a client, like a browser.
5
6
It extends from, and has access to all the methods of the :doc:`Request </incoming/request>` and :doc:`Message </incoming/message>`
@@ -10,7 +11,7 @@ classes, in addition to the methods listed below.
10
11
:depth: 2
11
12
12
13
Accessing the Request
13
-
---------------------
14
+
*********************
14
15
15
16
An instance of the request class already populated for you if the current class is a descendant of
16
17
``CodeIgniter\Controller`` and can be accessed as a class property:
@@ -28,7 +29,7 @@ the controller, where you can save it as a class property:
28
29
.. literalinclude:: incomingrequest/003.php
29
30
30
31
Determining Request Type
31
-
------------------------
32
+
************************
32
33
33
34
A request could be of several types, including an AJAX request or a request from the command line. This can
34
35
be checked with the ``isAJAX()`` and ``isCLI()`` methods:
@@ -59,7 +60,7 @@ You can also check if the request was made through and HTTPS connection with the
59
60
.. literalinclude:: incomingrequest/006.php
60
61
61
62
Retrieving Input
62
-
----------------
63
+
****************
63
64
64
65
You can retrieve input from ``$_SERVER``, ``$_GET``, ``$_POST``, and ``$_ENV`` through the Request object.
65
66
The data is not automatically filtered and returns the raw input data as passed in the request.
@@ -151,7 +152,7 @@ All of the methods mentioned above support the filter type passed in as the seco
151
152
exception of ``getJSON()``.
152
153
153
154
Retrieving Headers
154
-
------------------
155
+
******************
155
156
156
157
You can get access to any header that was sent with the request with the ``headers()`` method, which returns
157
158
an array of all headers, with the key as the name of the header, and the value is an instance of
@@ -177,7 +178,7 @@ If you need the entire header, with the name and values in a single string, simp
177
178
.. literalinclude:: incomingrequest/019.php
178
179
179
180
The Request URL
180
-
---------------
181
+
***************
181
182
182
183
You can retrieve a :doc:`URI </libraries/uri>` object that represents the current URI for this request through the
183
184
``$request->getUri()`` method. You can cast this object as a string to get a full URL for the current request:
@@ -195,7 +196,7 @@ functions use, so this is a helpful way to "spoof" an incoming request for testi
195
196
.. literalinclude:: incomingrequest/022.php
196
197
197
198
Uploaded Files
198
-
--------------
199
+
**************
199
200
200
201
Information about all uploaded files can be retrieved through ``$request->getFiles()``, which returns an array of
201
202
``CodeIgniter\HTTP\Files\UploadedFile`` instance. This helps to ease the pain of working with uploaded files,
@@ -217,7 +218,7 @@ multi-file upload, based on the filename given in the HTML file input:
217
218
.. note:: The files here correspond to ``$_FILES``. Even if a user just clicks submit button of a form and does not upload any file, the file will still exist. You can check that the file was actually uploaded by the ``isValid()`` method in UploadedFile. See :ref:`verify-a-file` for more details.
218
219
219
220
Content Negotiation
220
-
-------------------
221
+
*******************
221
222
222
223
You can easily negotiate content types with the request through the ``negotiate()`` method:
223
224
@@ -226,7 +227,7 @@ You can easily negotiate content types with the request through the ``negotiate(
226
227
See the :doc:`Content Negotiation </incoming/content_negotiation>` page for more details.
227
228
228
229
Class Reference
229
-
===============
230
+
***************
230
231
231
232
.. note:: In addition to the methods listed here, this class inherits the methods from the
232
233
:doc:`Request Class </incoming/request>` and the :doc:`Message Class </incoming/message>`.
0 commit comments