WEBVTT

00:00.230 --> 00:04.280
Hey, everyone, and welcome back to the Knowledge Portal Video series.

00:04.280 --> 00:08.330
And in today, we'll be speaking about the head method.

00:08.360 --> 00:14.690
Now, we already had an overview about the head method in the earlier lectures when we ran Curl Hyphen

00:14.870 --> 00:21.260
Command, however, I decided to just have a dedicated lecture so that it will become easier for us

00:21.260 --> 00:22.040
to revise.

00:23.660 --> 00:32.410
So when you talk about a response which a web server will send, there are two parts in the response.

00:32.420 --> 00:36.320
One is the header fields and second is the message body.

00:36.320 --> 00:42.620
And this is very important because whenever a web server will send a response, if the first thing that

00:42.620 --> 00:48.830
it will show is the header field and after the header field, it will give us the message body if it

00:48.830 --> 00:49.760
is required.

00:49.910 --> 00:57.800
Now header field itself gives a lot of information like in here you say you see it is 200.

00:57.800 --> 00:58.010
Okay.

00:58.010 --> 01:01.080
That means the request has been successfully processed.

01:01.500 --> 01:05.220
Along with that you have various other important information like the date.

01:05.220 --> 01:10.950
So this is the date in which file was last updated or last modified.

01:10.980 --> 01:15.090
You have a content type, you have the content length.

01:15.120 --> 01:18.750
Content length is very important when you are sending a partial get request.

01:18.750 --> 01:23.100
I hope you remember and you have a cache control which is public.

01:23.100 --> 01:31.530
So these specific headers sometimes becomes quite important and there can be a possibility where client

01:31.530 --> 01:36.270
just needs to know the header field and not the message body.

01:36.660 --> 01:43.020
So if a client just wants to know the header field, then the head method is something which will be

01:43.020 --> 01:43.890
useful.

01:44.340 --> 01:51.740
So head method is used to fetch only the Http headers as part of the response.

01:51.750 --> 01:59.400
Now, whenever a head method is used, so a head method is very identical to a get method, except that

01:59.400 --> 02:04.410
the server must not return a message body in the response.

02:04.410 --> 02:05.670
This is very important.

02:05.700 --> 02:15.660
Whenever a head based header is sent to the web server, the web server should send the response but

02:15.660 --> 02:17.610
without the message body.

02:18.180 --> 02:22.950
Now the example is very simple You have a curl hyphen.

02:22.950 --> 02:30.630
I followed by the URL of the server for which you are sending a head based request.

02:31.170 --> 02:31.770
Perfect.

02:31.770 --> 02:33.600
So let's do one thing.

02:33.600 --> 02:40.520
Let's go ahead and I'll start Wireshark as well so that it will become much more simpler for us to see

02:40.530 --> 02:42.090
on what exactly is happening.

02:43.560 --> 02:44.460
I'll start.

02:44.460 --> 02:47.850
And this time let me do a curl.

02:50.760 --> 02:56.730
I say Dexter dot k p labs dot n say sample dot HTML.

02:58.860 --> 03:02.950
And now you will see it returned only the header fields.

03:02.970 --> 03:04.860
So I'll stop the wireshark

03:07.050 --> 03:13.140
and let's put http so that it will become much more simpler.

03:14.160 --> 03:16.080
So this is the Http.

03:19.520 --> 03:21.810
Packet corresponding to a keyword request.

03:21.810 --> 03:29.550
So if I do a http stream now, what you will see is what curl did.

03:29.570 --> 03:30.020
Curl.

03:30.020 --> 03:35.800
Instead of sending get it, send a head for slash sample dot HTML.

03:35.810 --> 03:44.210
So now in response to this, what a web server did, web server sent only the response header.

03:44.210 --> 03:46.700
It did not send the message body.

03:46.880 --> 03:56.150
However, if you remove the hyphen I over here you will find that it now sent the response body as well.

03:56.150 --> 04:02.480
And this is the basics about the Http head method.

04:02.510 --> 04:09.230
Again, this becomes very very important because you need to know on what are the parameters which your

04:09.980 --> 04:13.720
web server is accepting for a specific resource.

04:13.730 --> 04:19.880
This also helps a lot in cache control as well as partial gets as well.

04:19.880 --> 04:26.060
So we'll be looking into this once we go ahead and work with a web server.

04:26.070 --> 04:28.340
Nginx in great detail.

04:28.340 --> 04:30.290
So this is it about this lecture.

04:30.290 --> 04:37.100
I hope the basic Http head header is understood and if you have any doubts, questions, suggestions,

04:37.100 --> 04:43.540
feel free to connect us at Twitter, Facebook or LinkedIn or mail us at instructors at their labs dot

04:43.550 --> 04:43.680
in.

04:43.730 --> 04:44.960
Thanks for watching.
