HTTP PROTOCOL




HTTP stands for hypertext Transfer Protocol it is an application layer protocol that allows web based applications to communicate and exchange data you can think of the HTTP as the messenger in the web it is tcp/ip based protocol and it is used to deliver contents for example images videos audios documents etc and if two computers wants to communicate and exchange data namely the client and the server usually in form of a request response cycle those two computers must speak both of them the HTTP communication protocol the client is the computer that makes the request and the server is the one that serves by responding to the request now before talking about the how and the why you need to know three important things about the HTTP protocol the first thing is that the HTTP protocol is a connectionless protocol that is to say the computers that communicate via the HTTP as we said in a request response cycle after making the request the two computers disconnects from each other and when the response is ready the connection reestablishes again to deliver the response then it closes so this is what we mean by a connectionless protocol the second thing is that the HTTP can deliver any sort of data as long as the two computers are able to read it the third thing is the HTTP is a stateless protocol the HTTP is a stateless protocol in other words the client and server know about each other just during the current request if the connection closes completely and the two computers want to connect again they need to provide information to each other any and the connection is handled as the very first one there are other important things in features about the HTTP but we are not going to talk about them here and before explaining how the web works let's see why choosing the HTTP over something else HTTP was created first to fetch HTML documents and sends it back to the client so we can say that the HTTP was designed for the web in the first place that's all what the hitch TDP was doing in the 1991 and it didn't support other media types just delivering HTML documents but because it was designed in an exquisite way and it was being continually evolved and features were being added to it it became the most convenient way to quickly and reliably move data on the web and it features a lot of advantages that go beyond the scope in this video so let's move to the most important part the action part how the web works and how the HTTP makes that possible first let's see how the request response cycle happen here we have the client on the left and the server on the right a user wants to see a website for example www.webociti.com forward slash products forward slash my product HTML the user type in the URL of the page using a client program usually a browser but first they need to be physically connected I mean the computer of the user and the web server that's the job of the internet using the tcp/ip suite of protocols it establishes the connection using a combination of cable media and wireless media and do all the necessary work to prepare the environment for the two computers to talk via the HTTP protocol when the connection establishes the client sends a request called an HTTP message and because the HTTP is a connectionless protocol the client disconnects from the server waiting for the response the server on the other side process the request prepare the response establishes the connection again and send back the response again in form of an HTTP message to the client then the two computers completely disconnect that was a bit general now because the HTTP is a protocol it is defined by a set of precise rigorous rules let's take a close look at ttpm message first the HTTP consists of three main sections the salt line the headers and the body and they all contain plaintext information unless if the body contains binary data but in general HTTP messages are plain text and easy to read the information in the three sections very dependent on the HTTP message whether it is a request or a response a request HTTP message differs from a response one and this is the information they contain we're going to take a close look at each one of them first let's look at a request HTTP message let's use our HTTP requests of our user here we have the start line on the top which contains the method the URI and the HTTP version we'll talk about those in a little more details in a few and we have the headers the headers are basically name value pairs and there can be a lot of headers but let's just be content with these three okay the host accept and accept language and the body doesn't exist because it's not needed now let's talk about them in detail in the start line the first thing we find is the method basically the method is a sort of command from the client it tells the server what it should do for example give me data delete this or put this in the database there is two well-known HTTP methods and you've most likely heard of them they are they get to tell the server to send you the data and the post to tell it to store data in the database and there are others such as put delete etcetera in our user case the method is get because the user wants to display a web page on the browser so he is asking the server to give him the web page then we have the URI Uniform Resource identifier the URI is a set of readable characters in a way to locate the resources we are requesting from the server for example in our case is products /my products dot HTML and we have the HTTP version that the client is using so that the server understands the message well the headers specifies some information in rules for example the host which is the address of the server to which we are sending the request which is www.cms.gov the file where a question it holds a miami type has its value a miami type looks like this file type forward slash extension for example image /f text forward slash HTML etc let's talk now about a response HTTP message as always we have this sort line but in the response we don't have a URI in the method because those are specifically for the requests so here we have the HTTP version with this code that is called the status code and this code tells the client if the request succeeded or failed it may contain 200 Colin okay which means the request succeeded or it may contain the well-known code that every web user knows the 404 colon file not found status code and there are other codes the headers contain also name value pairs such as except language or content length etc and finally the response body contains the requested file of course in our case this is the response message so that's how an HTTP message can look like of course an HTTP message can be more complicated than our example and contains a lot of other information also a client can send multiple HTTP requests to the server that was how the HTTP protocol works in general if you want to know more you've got to search more and actually there are good books out there about the HTTP protocol but this was just a brief overview to sum up we've seen that the HTTP is a tcp/ip based application layer protocol that allows web based applications to communicate and exchange data and computers does communicate via the HTTP must speak the HTTP protocol also we've seen three important features about HTTP which are that HTTP is a stateless connectionless protocol and can deliver any data also we use the HTTP protocol because it is a convenient way to quickly and reliably move data on the web we've seen that the request response cycle works on the web via HTTP messages and also HTTP message contains three sections the salt line the headers and the body and an HTTP request message differs from an HTTP response message so that's it for this video I hope you've learned something from it and don't forget to subscribe till the next video stay tuned

Post a Comment

Previous Post Next Post