We call up web pages using the HTTP protocol, and the browser communicates with the web server. But how does this communication work?
The HTTP protocol regulates how clients (browsers) formulate requests and how servers respond to them. For this purpose, there are special request methods, so-called HTTP requests. The Unified Resource Identifier (URI) plays an important role here. URIs are used to designate resources on the Internet. A URI is the address of a website (resource). Example: tecomon.de. The associated URL in this case would be https://tecomon.de/.
GET and POST
The ancestor of HTTP requests is GET. It has existed since the beginning of the World Wide Web and is used to request files from the web server. When you enter a URL in your browser, it connects to the web server and sends it the GET request. A parameter (e.g. transferred form data), separated by a question mark, is added to the URI. An example would be "tecomon.de/index.php?suche=aktuelles". The data to be sent to the server is thus written directly into the URL. The advantage: URL parameters can be saved together with the website address and retrieved via the browsing history. Disadvantage: All data that you transmit is openly transmitted via the browser's address line.
However, when logging into a platform, we don't want our username and password to be publicly displayed in our browser's address bar. Therefore, if you want to send large or confidential amounts of data, the GET method is not ideal. That's why we have POST. This method does not write the parameters into the URL, but only into the HTTP request for the server. The data is not visible to the user. The POST method thus provides discretion and is important for handling sensitive data. The data is also not stored in the cache or in the browser history. However, this is also the disadvantage of POST. When a web page with a form is refreshed in the browser (e.g. when the "Back" button is pressed), the form data must be transmitted again. It can happen that unwanted duplicate orders are thus triggered for an order form. However, modern web store programs can prevent this.
Nowadays, GET is mostly used for filtering, sorting and searching inputs. POST, on the other hand, to transmit information and data from the user.
Other request methods
Apart from the two HTTP requests presented here, there are a number of other request methods. OPTIONS provides a list of supported HTTP methods of the server. TRACE can be used to follow routes through which an HTTP request goes to the server and from there back to the client. This way it can be checked if and how the request has been modified on its way to the server. This method is important for testing programs and troubleshooting. Through HEAD, clients can first be told the file sizes and then decide if they want to receive the file. Also, other information can be obtained in advance and the document contents can be checked. For example, the validity of a file. PUT, PATCH and DELETE, are used to save, modify or delete files on the server. For security reasons, servers usually block these methods. Therefore, they hardly play a role in normal website programming. PUT, PATCH and DELETE are used in the WebDAV context and in connection with the REST API.