WEBVTT

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

00:04.490 --> 00:09.260
Now, today we will be speaking about partial get request.

00:09.260 --> 00:15.890
So let's get started with a very similar example that we have been discussing since past few lectures.

00:16.400 --> 00:18.320
So you have a client.

00:18.320 --> 00:21.770
So consider this as a web browser or a Telnet.

00:22.100 --> 00:28.460
And on the right hand side you have a web server which has a file called as documentary dot mp4.

00:29.000 --> 00:37.580
Now, when a client makes a request to the web server of type, get so you have a get request on the

00:37.580 --> 00:44.750
documentary.mp for what a web server will do is that it will fetch the entire file and send it back

00:44.750 --> 00:46.100
to the client.

00:46.940 --> 00:56.600
Now what happens if a client wants to see only first five minutes or first let's assume 20s of documentary

00:56.810 --> 01:03.340
and before the client does not really want to see the entire content, just first 20s of the content.

01:03.360 --> 01:06.890
So what client will do along with the get request?

01:06.900 --> 01:09.180
This is the first mandatory step.

01:09.480 --> 01:14.900
Client will also specify that I want to watch only first 20s.

01:14.910 --> 01:19.320
So this is what client will specify to the web server.

01:19.650 --> 01:30.270
Now web server in response will say that here is the first 20s of the data and instead of sending the

01:30.270 --> 01:36.060
entire file, web server will send only partial part of that specific file.

01:36.750 --> 01:45.390
Now, if you look into the response header, you have Http 1.1 and instead of 200, okay, you have

01:45.420 --> 01:47.510
206 partial content.

01:47.520 --> 01:55.020
So this header specifies that the content which is being sent is only partial and it is not the entire

01:55.020 --> 01:55.620
file.

01:55.950 --> 01:59.220
So this is about the partial get request.

01:59.460 --> 02:09.120
So going back to a theoretical perspective, partial get method is used to retrieve only specific content

02:09.120 --> 02:11.400
instead of the entire file.

02:11.550 --> 02:17.490
So if you look into the example over here, you have get request followed by movie dot mp4.

02:17.700 --> 02:29.040
You have the http 1.1 protocol host is Dexter labs in and range is bytes 0 to 1 024.

02:29.070 --> 02:36.790
This basically means only send me the first 1024 bytes of the movie dot mp4.

02:36.810 --> 02:44.100
So once the web server receives this request, instead of sending the entire file, it was it will just

02:44.100 --> 02:50.520
send the first 1024 bytes of the file which is being requested.

02:50.730 --> 02:58.770
Now, one important thing to remember over here is that the partial get was introduced in the Http protocol

02:58.770 --> 03:00.410
version 1.1.

03:00.420 --> 03:06.370
So if you try to do it with 1.0 or 0.9, this will not work.

03:06.390 --> 03:09.080
It got introduced in 1.1.

03:09.090 --> 03:13.980
So if you want to have a partial get, you need to use Http 1.1.

03:13.980 --> 03:16.410
So one important thing to remember.

03:16.620 --> 03:19.290
So this is about the theoretical part.

03:19.320 --> 03:24.900
Let's go to our favorite lab section so that we can actually see on how this really works.

03:26.160 --> 03:27.420
So what I'll do.

03:27.450 --> 03:33.270
I'll type Dexter dot Labs dot in and I'll type partial dot txt.

03:34.890 --> 03:41.440
So if you see over here, the response has content numbers from 1 to 100.

03:41.460 --> 03:46.650
So these are all the numbers which is present in this partial dot txt file.

03:47.280 --> 03:55.770
Now, instead of using classic telnet this time we'll be using one more client which is very famous

03:55.770 --> 03:56.790
called as curl.

03:57.390 --> 03:59.130
So if you do a curl.

03:59.820 --> 04:07.010
Let's say Dexter dot labs dot n slash partial dot txt.

04:08.870 --> 04:10.820
Curl will give you a similar output.

04:10.820 --> 04:15.470
So you see, you got numbers from 1 to 100.

04:15.690 --> 04:22.220
Now Curl is very famous for its flexibility and customization features that it offers.

04:22.400 --> 04:28.400
So I can actually print out the response headers only.

04:28.790 --> 04:35.900
So if you do a hyphen I it will only print out the response headers and not the entire file.

04:35.930 --> 04:41.900
So let me show you on how that actually works so that it becomes much more clear.

04:42.170 --> 04:48.680
Let me start the Wireshark capture and I'll fire up the curl.

04:49.160 --> 04:50.940
So you got the response.

04:50.960 --> 04:54.740
Now I'll stop the Wireshark packet capture.

04:54.740 --> 04:59.480
And this is the request which was made, which is get slash partial dot txt on.

05:00.090 --> 05:01.030
1.1.

05:01.050 --> 05:05.520
So I'll right click here and I'll follow the http stream.

05:07.120 --> 05:12.970
So if you look into the request which curl automatically created.

05:12.970 --> 05:19.240
So whenever you type this command, whenever you type, this command curl will automatically formulate

05:19.270 --> 05:20.800
a get request for us.

05:20.830 --> 05:28.750
However, in case of Telnet, ideally we had seen on how we can write a get request manually.

05:29.230 --> 05:35.830
So curl created a request a get method for partial dot txt.

05:36.100 --> 05:42.000
The protocol is http 1.1 and the host is Dexter Labs dot n.

05:42.280 --> 05:43.810
And this request.

05:43.810 --> 05:49.270
This entire request was sent to the web server listening on Dexter Labs.

05:50.740 --> 05:59.080
Once the web server received this request, it responded back with the Http 1.1 200.

05:59.080 --> 05:59.410
Okay.

05:59.650 --> 06:00.520
200.

06:00.520 --> 06:00.820
Okay.

06:00.850 --> 06:05.410
Means the request that was sent by the curl was successfully processed.

06:05.410 --> 06:07.550
And this is the reason why you have 200.

06:07.550 --> 06:08.120
Okay.

06:08.750 --> 06:10.730
Followed by the other headers.

06:10.730 --> 06:16.850
It also tells us what is the version of web server which is being listened, which is nginx in our case

06:17.900 --> 06:20.170
after this response headers.

06:20.180 --> 06:22.400
So these are called as the request headers.

06:22.400 --> 06:24.440
These are called as the response headers.

06:24.680 --> 06:32.840
After this response headers, the web server which is Nginx, responded with the actual content of the.

06:34.110 --> 06:35.880
Bicycle dot txt file.

06:37.410 --> 06:48.780
So when you do a curl hyphen i what will really happen is that curl will only give us these particular

06:48.780 --> 06:49.290
headers.

06:49.320 --> 06:51.870
It will not send us the content.

06:51.870 --> 06:54.960
Which of the file which was been requested.

06:54.960 --> 06:56.940
Only the response headers.

06:56.940 --> 06:59.670
And you might ask do I really need response headers?

06:59.670 --> 07:01.350
And the answer is very well.

07:01.440 --> 07:07.560
So let's print the response headers and see on what kind of information it provides.

07:07.740 --> 07:14.220
Now, the first information it provides is whether the request was executed successfully or not.

07:14.220 --> 07:19.530
And since the response headers is 200, okay, it means that this request was successfully executed.

07:19.680 --> 07:22.890
Then you have the server which is Nginx.

07:23.040 --> 07:31.020
Now, next important header that will be discussing is the content type which says text slash plain,

07:31.170 --> 07:40.300
which basically says that this file, the partial dot txt or file is of type text.

07:40.810 --> 07:44.320
Then it tells about the content length.

07:44.350 --> 07:51.730
It says that the file which is being requested is of of size 292 bytes.

07:51.730 --> 07:57.460
So we can actually find the size of the file even without requesting it.

07:57.460 --> 07:58.870
This is very important.

07:59.440 --> 07:59.890
Okay.

08:00.730 --> 08:08.650
292 bytes and the last important header is the exit ranges which is of type byte.

08:08.800 --> 08:16.900
Now this is very this specific header is very important when it comes to partial get requests because

08:16.900 --> 08:21.870
this signifies which ranges does the server accept.

08:21.880 --> 08:26.410
So let's let me show you so that it will become much more clear.

08:26.410 --> 08:29.350
So I'll do a curl hyphen hyphen header.

08:31.390 --> 08:43.680
I'll say range range would be bytes 0 to 24 Dexter dot labs dot n slash partial dot txt.

08:44.160 --> 08:55.530
So now what this specifies is that curl will send a get request with a header range and the range is

08:55.530 --> 08:57.000
bytes 0 to 20.

08:57.030 --> 09:04.800
That means just I just need the first 20 bytes of the partial dot txt file.

09:04.800 --> 09:07.380
So this is what it really signifies.

09:07.650 --> 09:18.030
So if I press enter you will see instead of entire file it is only sending me the first 20 bytes of

09:18.030 --> 09:20.370
the partial dot txt file.

09:20.790 --> 09:22.440
So let's do one thing.

09:22.440 --> 09:27.600
Let's fire up the wireshark so that we can see the request headers.

09:31.120 --> 09:31.500
Okay.

09:31.510 --> 09:32.620
And

09:35.170 --> 09:35.830
I'll press.

09:35.830 --> 09:37.990
And you got the first 20 bytes.

09:38.410 --> 09:41.170
So now if I'll stop over here.

09:41.860 --> 09:43.930
Let's go a bit down.

09:44.890 --> 09:46.540
This is our stream.

09:46.540 --> 09:48.250
I'll do a follow Http stream.

09:48.460 --> 09:56.710
So now if you'll see, when we entered this command, when we entered the Curl command, we also specified

09:56.710 --> 10:01.360
a an additional header which it should send to a web server.

10:01.360 --> 10:03.040
And this is the header.

10:03.160 --> 10:05.560
Now Curl will add that header.

10:05.560 --> 10:14.260
So if you see over here, Curl has added one more header called as range with bytes 0 to 20 and this

10:14.260 --> 10:17.740
is what the hyphen hyphen header command actually does.

10:19.330 --> 10:27.550
After this specific request was sent, the Nginx server sent a Http response.

10:27.550 --> 10:30.230
You see 206 partial content.

10:30.230 --> 10:34.490
That means the content that is being sent is of partial type.

10:34.490 --> 10:36.230
It is not the entire file.

10:36.770 --> 10:42.170
Along with that, it tells the content length of the new content which was being sent.

10:42.170 --> 10:52.880
And in the content range header you will see byte is 0 to 20 slash to 92, which signifies out of 292

10:52.880 --> 10:55.130
bytes of the partial dot txt.

10:55.430 --> 11:03.020
Only the bytes ranging from 0 to 20 have been sent back to the client.

11:03.740 --> 11:12.650
Now you can actually modify these value as well, so I can put 20 to 40.

11:15.530 --> 11:18.890
And now you see accordingly you get the information.

11:18.890 --> 11:27.380
Now, this is a commonly used in a downloading website, like there are various websites where you download

11:27.380 --> 11:34.490
files from, and some of these websites will not allow you to resume file for free users.

11:34.490 --> 11:38.900
However, some websites will allow to resume files for free users.

11:39.380 --> 11:49.000
So how they actually do it is that let's assume I'm a free user and I have downloaded content from 0

11:49.000 --> 11:54.920
to 20 bytes, so this much amount of content got downloaded and my internet got disconnected.

11:55.280 --> 12:05.870
So after my internet resumed again, I would ideally want to download file from 20, say, let's say

12:05.870 --> 12:10.190
from 20 to the last byte, which is let's assume to 90.

12:10.340 --> 12:19.320
However, since I'm a free user, what the downloading website does is it will not allow you or it will

12:19.320 --> 12:22.410
not respond with the range header.

12:22.410 --> 12:28.230
It will ask you to start downloading from the absolute zero.

12:28.590 --> 12:34.260
However, for premium users who have paid money, it will allow the range header.

12:34.260 --> 12:40.770
And if you want to resume your downloading from the 21st byte, that will be possible.

12:40.770 --> 12:49.650
So this is how the file downloading websites can block free users from resuming the operations.

12:49.950 --> 12:51.240
So this is it.

12:51.240 --> 12:52.470
About this lecture.

12:52.470 --> 12:58.170
I hope the partial Http get method is understood by you.

12:58.260 --> 13:03.570
And again, if you have any doubts, suggestions, questions, feel free to connect us at Twitter,

13:03.570 --> 13:08.460
Facebook or LinkedIn or mail us at instructors at the Rate Labs dot n.

13:08.490 --> 13:09.690
Thanks for watching.
