HTTP stands for Hypertext Transfer Protocol. There is an article called HTTP: The Protocol Every Web Developer Must Know – Part 1 that is a good read. This post is based on that article. Below is a graphic from that web site that shows the different parts of a URL.
Mozilla.org has a web page with a lot of information about HTTP.
HTTP works as a request-response protocol between a client and server. A web browser may be the client, and an application on a computer that hosts a web site may be the server.
The protocol is typically http, but it can also be https for secure communications. The default port is 80, but one can be set explicitly, as illustrated in the above image. The resource path is the local path to the resource on the server. Notice that the query is in the form of name/value pairs separated by the ampersand character.
Verbs
URLs reveal the identity of the particular host with which we want to communicate, but the action that should be performed on the host is specified via HTTP verbs. These are http request methods. GET and POST are the two most significant methods. Web developers need to know their methods.
GET Requests
The website w3schools.com makes the following points about GET requests.
- GET requests can be cached
- GET requests remain in the browser history
- GET requests can be bookmarked
- GET requests should never be used when dealing with sensitive data
- GET requests have length restrictions
- GET requests should be used only to retrieve data
Here are some observations from the Assertible website in an article called 7 HTTP Methods every… : “GET requests are the most common and widely used methods in APIs and websites. Simply put, the GET method is used to retrieve data from a server at the specified resource. For example, say you have an API with a /users endpoint. Making a GET request to that endpoint should return a list of all available users. Since a GET request is only requesting data and not modifying any resources, it’s considered a safe and idempotent method”.
POST Requests
w3schools makes the following points about GET requests.
- POST requests are never cached
- POST requests do not remain in the browser history
- POST requests cannot be bookmarked
- POST requests have no restrictions on data length
Assertible.com says: “In web services, POST requests are used to send data to the API sever to create or udpate a resource. The data sent to the server is stored in the request body of the HTTP request. The simplest example is a contact form on a website. When you fill out the inputs in a form and hit Send, that data is put in the response body of the request and sent to the server. This may be JSON, XML, or query parameters (there’s plenty of other formats, but these are the most common). It’s worth noting that a POST request is non-idempotent. It mutates data on the backend server (by creating or updating a resource), as opposed to a GET request which does not change any data. Here is a great explanation of idempotentcy.”