Request-Response Cycle
We’ve all heard the term HTTP, and many of us are now familiar with how it is the backbone of the internet, but what exactly is Hypertext Transfer Protocol and how do we use it to help webpages communicate with our devices? Firstly, we need a webpage for consideration. You will need to reference this website using its URL/URI, the Uniform Resource Locator/Identifier. We are all familiar with typing into our browsers everyday a clean and abbreviated form (ex: Twitter.com) in order to point to an IP address. while we could go and grab the full URL, our modern web browsers know to fill in the important details like “https://www.” before loading the site.
A DNS, Domain Name System, converts our human words into a valid IP address if a site is registered with that keyword (think about it, you never type an IP address to visit Twitter, you use their shorthand website name). The HTTP protocol can be used for fetching documents of course, but it can fetch other resources as well, or do other actions like post data to another server. These actions are HTTP Verbs, which describe the ability to Create, Read, Update, and Delete data. In specific to HTTP, we can program our site with the ability to POST, GET, PUT, PATCH, and DELETE.
The website itself is being hosted on a server so you can access it from anywhere with internet connectivity. The device you are using to view the website is known as the client. As you interact with a website, especially if you log into an account, you become a user. Changes you make on the site reflect specifically onto your screen by rendering changes locally to the Document Object Model, DOM, so of course when you log in to see your account it is only happening on the one client you are using. As a user makes changes on the DOM by interacting with the site through buttons or forms, etc, this sends requests to the server, the function and relevant data are processed and it sends a response back to complete the cycle.
It is important to remember that the requests are made by the browser and are then handled on the server and sent back as a response to the client. These requests and responses are stateless, so any two consecutive requests may not necessarily relate to each other. This also brings in the issue of persisting data on the site, such as a shopping cart feature. Websites use cookies, locally stored files with data relevant to that site, to help the site speed up interactions, store user profile details, or even website settings. This also allows a user to stay logged into an authentication session while navigating between pages. Without accounting for this, a user could be interacting with the site in a meaningful way, but the results would not necessarily be reflecting the expected results. We as programmers have to take this into account as we build our sites.
The structure of an HTTP Request:
Get Greg Banks’s stories in your inbox
Join Medium for free to get updates from this writer.
An HTTP request includes a method, path, version of HTTP protocol, optional headers, and optional body.
Method: These are our CRUD actions for POST, GET, PUT, PATCH, and DELETE.
Path: Is where the HTTP request should be directed for a specific resource.
Version: The version of HTTP protocol being used.
Headers: May provide additional information.
Body: This is typically included with POST requests to include the client resource being sent to the server.
Some sites may also use a middleman of sorts between its server and your client, this is known as a Proxy. The HTTP proxy operates between the server and client. This can be used as a security feature to potentially stop harmful content before sending it to a client. It also protects against harmful Web clients through compliance and it can mitigate or prevent buffer overflow attacks on the server.









