Hey, everyone, and welcome back to the Knowledge Portal Video series.
Now, in the earlier lecture we were discussing about the Http protocol.
So continuing our journey with it today, we'll be understanding our first Http protocol method, which
is get.
So let's go ahead and understand more about it.
So Http get request is a very simple method which is generally used to fetch the information which is
specified in the request.
Uri.
So the syntax is get followed by the request uri.
So if you're not aware what a request Uri is all about, let's take a very simple example for this.
So I'll open up my atom editor and there are three URLs which are present over here.
One is Dexter's labs in slash sample dot HTML.
Then you have Dexter's labs in slash index.html and Dexter labs in slash video dot mp4.
Now in all of these the first.
Entity remains the same, which is Dexter Labs.
And so you find that the server is the same and then you have a unique resource which you are mentioning
over here.
So this is the unique resource or a unique file is sample dot HTML.
In the second request you have index dot HTML and the third request that is video dot mp4.
So this specific parameter which signifies the unique file within the server is called as the request
uri.
So let's try this out.
So I'll copy this and I'll paste it here.
So now you have a sample dot HTML file.
Let's modify this and put index dot HTML and you have a different page load altogether.
So you have a different page over here.
You have a different page over here.
The reason is because here you are calling a file or a resource called a sample dot HTML.
And here you are calling a resource called as index dot HTML.
So the parameter which calls the unique resource within the server, in this case it is slash sample
dot HTML is called as the request Uri.
Perfect.
So going back to our presentation.
Get method is used along with the request uri.
So when you talk about one of the example you have get slash admin followed by the http 1.1.
So there are various Http protocols like 0.9.
It all started with then you have 1.0, you have 1.1, and now even 2.0 is present.
So depending upon the protocol language, which your browser is speaking, the protocol version might
change one.
Point one is a fairly common protocol version which is being used and in the next line you have host
followed by Dexter dot CPU Labs dot n.
So this entire request is interpreted as Dexter dot Labs dot n slash admin.
So this is what it signifies.
Perfect.
So this is a very simple get request.
There are various type of other get requests which is being used and one is called as the conditional
get request.
So conditional get method is generally used to fetch information with a specific condition.
So let's take an example.
You have get slash sample dot HTML.
You have the Http protocol version, which is Http 1.1.
Host this Dexter labs in and the condition here is if modified since Saturday 29th October 2017, followed
by the time in GMT.
So what is basically means get me sample dot HTML file from Dexter labs dot in server only if it is
modified after this specific time.
If it is if sample dot HTML is not modified after this specific amount of time, then the web server
will send a 304.
It will not fetch this specific resource.
If it is modified, then the web server will send the entire sample dot HTML files content back to the
client.
So this is the conditional get.
Let's talk about one more method which is partial get.
So a partial get method is used to retrieve only specific content instead of everything by default.
So let's take an example.
You have get followed by the request url slash movie dot mp4, then http 1.1 and the host is Dexter
Labs dot in.
And in the third line there is one header which is added, which is range followed by bytes which is
0/1 0 to 4.
So what this basically means that I don't really need the entire movie dot mp4 file because it might
be very big as well.
I only need the first one 0 to 4 bytes of this specific movie dot mp4 file.
And this is what a partial get means.
It means give me only partial information instead of the entire file.
So this is very useful.
And in youtube.com you will see whenever you load a video, entire video is not streamed, only a specific
information is streamed at the start.
And when you complete it, then next range of information gets streamed.
So we'll understand this with an example in the upcoming lecture.
And let's do one thing.
Let's write our first get request, not with the web browser, but with a manual handwritten request.
So when you manually write things, it gives you a lot of satisfaction and it will help you understand
things in more detail.
So let's try this out.
Let me check if I can zoom this more so that it will become much more visible.
I hope this is much more visible now.
So let's do a telnet on Dexter Labs dot in followed by the port.
Port is 80.
So 80 is the port in which the web server is listening.
I'll press enter so it stays connected.
And now since we are connected, we can write our first Http based request.
So our request will be get slash sample dot HTML followed by the http 1.1.
So we'll write this and now in the host we'll say Dexter dot Labs dot in, I'll press enter twice.
And now you see the web server gave us a response saying that 200.
Okay.
200.
Okay.
Means that this request is successfully processed and it gave us range of headers.
After giving the range of headers, it gave us the actual file, which is this is sample file.
And then it states specially designed for your handwritten get request.
And whenever you open this in the browser, you directly get this specific file.
Browser in turn creates this specific Http request and sends it to the server.
Now, instead of browsing, instead of browser formulating this request, we have actually written it
in a handwritten format.
So I hope you got the basic idea on how exactly the request is sent to the server and the response is
received.
So go ahead and try this out in your site as well so that it will give you a much more better understanding
on how things would really work.
So I hope this has been informative for you.
And in the next lecture we will be speaking more about the conditional get and the partial get, and
we'll look into how that would really work.
So this is it about this lecture.
I hope this has been informative for you and if you have any doubts, questions, suggestions, feel
free to connect us at Twitter, Facebook or LinkedIn or email us at instructors at the Labs dot n.
Thanks for watching.