HTTP

Share

What is HTTP?

HTTP is the name of the technology used to send and receive data on the web. It stands for HyperText Transfer Protocol. Any URL that starts with http: uses this protocol. URLs that start with https: use HTTPS, which is a more secure version of this protocol that encrypts the data sent and received.

HTTP is used to transfer HyperText Markup Language (HTML) files. When you access a webpage, your web browser automatically downloads a HTML file from a web server, and in this file is contained HTML source code that tells your web browser what to display on the screen. A single HTML file may declare URLs of resources used by the webpage, such as images, CSS, and Javascript files, which are also transferred via HTTP.

In the HTTP protocol, if a resource specified by a URL is found in a web server, the web server should, generally, respond with a 200 OK HTTP status code. If the resource isn't found, it responds with 404 NOT FOUND. If the server knows the resource existed, but it has been deleted permanently, 410 GONE. If the resource is found at a different URL, 302 FOUND. In this last case, the web server should also tell the web browser the new URL of the resource, and the web browser will automatically visit this new URL. This is called a redirect. If an error occurred producing the request, 500 INTERNAL SERVER ERROR.

The HTTP protocol has two "verbs" that are used by web browsers: GET and POST. In principle, GET requests don't have side-effects. This means that you should be able to GET the same URL as many times as you wish without changing anything. By contrast, POST may have side-effects. For example, a form that posts something to social media or to a forum has side effects: a new post will be created. Each time we POST to the same URL, a new post will appear, which means that a web browser can't automatically visit this URL with this verb because it may end up posting something you didn't mean to. Despite the name, POST is also the verb used for deleting posts, for updating posts, for changing settings, etc. It's possible to GET and POST the same URL, and this often has different effects, e.g. GET may display a form, while POST may make the web server process the form. Sometimes you may see a message saying that you must "resubmit" a form when you try to refresh a webpage. That's because that webpage was generated by a POST request, and the web browser isn't smart enough to know sending the same request again won't end up creating or deleting things.

Comments

Leave a Reply

Leave your thoughts! Required fields are marked *