Request

An Hypertext Transfer Protocol (HTTP) request is a query made to a web server. A client makes the request. A client can be a browser, an application with API access, or a development tool such as Postman.

A request is made to an endpoint.

Lifecycle

When the server receives a request, it processes it. Usually, this includes validating the request, processing any data submitted, and then give a proper response. After the server answers the client, the request lifecycle is over.

Requests are stateless. When a web server receives two requests, they don't know anything about each other. Sessions can manage state across multiple requests.

Methods

A client can interact with a server in multiple ways. To indicate which method the client is using a request method is used. The available methods are GET, HEAD, POST, PUT, PATCH, DELETE, OPTIONS, CONNECT and TRACE.

GET is the most common request method. This method indicates that the client wants to receive information. Information can be an HTML file or JSON data. GET requests fetches a single resource or a list of resources from an API. GET requests a single file or multiple files when a page loads.

Another common type is POST. This method indicates that the client wants to send information to the server. This information should be stored as a new resource by the application. The information submitted to the server is often in the form of JSON.

Other common request types are PUT and PATCH for updating resources and DELETE for removing resources.

Headers

A request header is a piece of meta information passed between the client and the server. A request can have multiple headers. Each header is a key-value pair.

Each request usually has a variety of different headers with information about language, device, browser, etc. The client automatically creates these.

Developers can manually create headers. Authentication methods using tokens often pass the token as an Authorization header to the server.

Authentication scaffolding

Starter kits for Laravel, Vue and React.