Junior — Middle
Can you name the components that are part of the HTTP request structure?
sobes.tech AI
Answer from AI
An HTTP request consists of several main components:
-
Request Line — contains the method (GET, POST, etc.), URI (resource path), and HTTP protocol version.
-
Headers — key-value pairs that convey additional information about the request, such as content type, authorization, cookies, etc.
-
Body — an optional part used to transmit data (for example, in POST or PUT requests).
Example of an HTTP request:
POST /api/login HTTP/1.1
Host: example.com
Content-Type: application/json
Authorization: Bearer token
{"username":"user","password":"pass"}
In iOS, creating HTTP requests typically involves using the URLRequest class, where all these components can be set.