Senior
What parts does an HTTP request consist of?
sobes.tech AI
Answer from AI
An HTTP request consists of several main parts:
-
Request Line — contains the method (GET, POST, etc.), URL (resource path), and HTTP protocol version.
-
Headers — a set of key-value pairs that convey metadata about the request, such as content type, cookies, authorization.
-
Blank line — separates headers from the body of the request.
-
Body — an optional part that contains data sent to the server (for example, in POST requests).
Example of a request line:
POST /api/user HTTP/1.1
In Go, when working with the net/http package, these parts are accessible through the http.Request structure.