1
00:00:00,210 --> 00:00:00,700
Beautiful.

2
00:00:01,020 --> 00:00:07,740
And once we have a general understanding how data is exchanged on the Web, let's also cover how HTP

3
00:00:07,740 --> 00:00:09,750
messages are structured.

4
00:00:10,170 --> 00:00:16,410
Please keep in mind that since it's going to be a big part of our job, we'll come back to this particular

5
00:00:16,410 --> 00:00:18,050
slide more than once.

6
00:00:18,480 --> 00:00:24,900
So if you hear about something, just please be patient and I'll answer all of your questions as we

7
00:00:24,900 --> 00:00:26,170
move along with the course.

8
00:00:26,550 --> 00:00:31,300
With that said, the general structure for both messages is similar.

9
00:00:31,710 --> 00:00:33,390
They both have a startling.

10
00:00:34,260 --> 00:00:41,970
They both have optional headers, a blank line that indicates that all the info has been sent and effectively

11
00:00:41,970 --> 00:00:46,650
headers are that info as well as optional body.

12
00:00:47,010 --> 00:00:49,970
And before we continue again, let me stress something.

13
00:00:50,340 --> 00:00:56,250
So request messages are what the user is sending.

14
00:00:56,670 --> 00:01:03,420
For example, if you open up the browser to search the web, or that could be your Web application.

15
00:01:03,600 --> 00:01:09,660
The remember, with Web applications, we also can make HTP request correct.

16
00:01:10,020 --> 00:01:14,090
And that response is going to be our responsibility.

17
00:01:14,550 --> 00:01:20,820
So we'll have to set up a proper server that sends a correct response.

18
00:01:21,630 --> 00:01:28,770
And in general, when we talk about the request message in start line, there's going to be a method

19
00:01:29,310 --> 00:01:33,270
then the URL as well as the HTP version.

20
00:01:33,660 --> 00:01:40,470
Now, we are mostly going to be interested in these two things in the method as well as the URL.

21
00:01:40,860 --> 00:01:47,640
Now there's going to be a separate slide about the methods as well, and the warranty will cover that

22
00:01:47,820 --> 00:01:52,750
in greater detail once we cover them with actual code examples.

23
00:01:52,780 --> 00:01:54,720
So I'll come back to that slide.

24
00:01:54,720 --> 00:02:00,060
Just understand the general idea that why don't we talk about methods effectively.

25
00:02:00,060 --> 00:02:02,580
We're communicating what we would want to do.

26
00:02:03,180 --> 00:02:09,340
For example, if I want to get the resource, I'm going to set it up as a get request.

27
00:02:09,750 --> 00:02:14,010
Now, if I want to add the resource, then of course this is going to be a post request.

28
00:02:14,370 --> 00:02:16,960
And then, of course, you can read the rest.

29
00:02:17,340 --> 00:02:24,840
Now, while I'm displaying here this get because that is the default request that the browser performs.

30
00:02:25,270 --> 00:02:29,150
Since when we open up the browser, we want to get some kind of research.

31
00:02:29,670 --> 00:02:30,120
Correct.

32
00:02:30,390 --> 00:02:33,030
That's why we're performing a good request.

33
00:02:33,300 --> 00:02:36,360
And the URL is just the address.

34
00:02:36,780 --> 00:02:43,150
And that could be, for example, John Smil dot com or that could be, I don't know, ESPN sports like

35
00:02:43,410 --> 00:02:44,180
basketball.

36
00:02:44,310 --> 00:02:47,130
Both of them are just a Web addresses.

37
00:02:47,430 --> 00:02:55,100
Now, ours is essentially optional where this is a matter of information about our request.

38
00:02:55,440 --> 00:03:00,320
And just to give you a general idea how the headers would look like they would look something like this.

39
00:03:00,420 --> 00:03:02,690
So it is a key value pairs.

40
00:03:03,030 --> 00:03:04,470
Now, don't freak out.

41
00:03:04,890 --> 00:03:09,060
As you know, when you search the web, you don't need to add the manually.

42
00:03:09,300 --> 00:03:12,260
And the same is going to be with our server.

43
00:03:12,600 --> 00:03:15,030
A lot of it is going to be taken care of.

44
00:03:15,030 --> 00:03:18,880
But yes, some things will have to add on our own.

45
00:03:19,240 --> 00:03:27,240
Basically, this is going to be information about our message and then we also have optional body.

46
00:03:27,660 --> 00:03:33,510
So when the user is requesting something, if you just want the resource, there is no body.

47
00:03:33,930 --> 00:03:35,430
There's nothing basically.

48
00:03:35,430 --> 00:03:40,650
What however, if we would want to add a resource onto the server.

49
00:03:40,650 --> 00:03:41,160
Yes.

50
00:03:41,430 --> 00:03:44,580
Then you are expected to provide that there.

51
00:03:44,670 --> 00:03:46,920
And it's also called payload.

52
00:03:47,130 --> 00:03:50,330
So again, I might use them interchangeably.

53
00:03:50,400 --> 00:03:53,460
So that's the general structure of the request message.

54
00:03:53,940 --> 00:03:55,020
We have to start line.

55
00:03:55,020 --> 00:03:56,130
We have the headers.

56
00:03:56,490 --> 00:04:03,150
That is the information about our message as well as the black line, which just indicates that we're

57
00:04:03,150 --> 00:04:08,430
done with the information and optional body, which we'll use from time to time.

58
00:04:08,820 --> 00:04:12,720
And of course, we need to talk about the response message.

59
00:04:13,020 --> 00:04:16,529
So our response message is what we are going to be creating.

60
00:04:16,560 --> 00:04:23,520
Again, most of it will be done for us, but some parts, yes, we'll have to do it manually and it's

61
00:04:23,520 --> 00:04:24,870
going to be our responsibility.

62
00:04:25,230 --> 00:04:30,540
So the START line has the DP version, which most likely is going to be one point one.

63
00:04:30,840 --> 00:04:34,870
Then we have a status code and status text.

64
00:04:35,310 --> 00:04:43,320
Now, when it comes to status code, it just signals what is the result of the request.

65
00:04:43,330 --> 00:04:49,230
So, for example, notice here this two hundred, that means that request was successful.

66
00:04:49,410 --> 00:04:51,000
So that's what we're sending back.

67
00:04:51,330 --> 00:04:54,180
And yes, there's quite a few of those codes.

68
00:04:54,450 --> 00:04:58,590
And as we move along with a course, of course we will cover them.

69
00:04:58,590 --> 00:05:05,610
But please, please, please don't rush over to the search engine and start memorizing the status codes

70
00:05:05,910 --> 00:05:08,310
pretty much as we're going to be building the application.

71
00:05:08,670 --> 00:05:12,420
I'll tell you which code means what, for example.

72
00:05:12,420 --> 00:05:16,830
Four hundred means that there was some kind of request error.

73
00:05:17,250 --> 00:05:21,480
So the user was trying to request some kind of research.

74
00:05:22,290 --> 00:05:25,320
And with four hundred, there was a request.

75
00:05:25,590 --> 00:05:30,690
Now, for example, the code four or four means that the resource is not fun.

76
00:05:30,930 --> 00:05:33,320
So when I'm sending back the message, I'm like.

77
00:05:33,620 --> 00:05:39,500
Hey, listen, here's the status code for the message, if you are successful, here's two hundred.

78
00:05:39,740 --> 00:05:43,340
If there was an error, for example, you get a four hundred.

79
00:05:43,550 --> 00:05:50,180
If the request is unauthorized, then you can get four on one and hopefully you get the gist.

80
00:05:50,180 --> 00:05:55,600
And yes, of course, as we're progressing, we will cover more status code.

81
00:05:55,890 --> 00:06:04,990
Then again, we have the headers where basically we provide info about our message, our response message.

82
00:06:05,510 --> 00:06:10,640
And again, like I said, you won't have to type everything line by line.

83
00:06:10,850 --> 00:06:15,320
But effectively, it is a set up of key value pairs.

84
00:06:15,650 --> 00:06:18,380
And the ones that I would like to mention are these ones.

85
00:06:18,390 --> 00:06:19,610
Notice this content type.

86
00:06:19,610 --> 00:06:21,700
We have text HDMI.

87
00:06:22,040 --> 00:06:25,220
That is when we're sending back the HDMI.

88
00:06:25,460 --> 00:06:30,440
But also our second option is going to be sending back the data.

89
00:06:31,010 --> 00:06:36,110
So hopefully you are aware that when you're building a Web application, when we communicate with API,

90
00:06:36,290 --> 00:06:43,550
most of the time we're getting back the JSON data because over the web, effectively we just send over

91
00:06:43,550 --> 00:06:44,050
the string.

92
00:06:44,510 --> 00:06:50,780
So if, for example, I have some kind of array, we transfer this into application duration.

93
00:06:51,020 --> 00:06:58,220
And I clearly indicate that in my headers when I say that, no, I'm not sending text and email, I'm

94
00:06:58,220 --> 00:07:00,890
actually sending a application, Jason.

95
00:07:01,220 --> 00:07:05,150
And then that application, who is requesting the Web application, knows that.

96
00:07:05,150 --> 00:07:09,970
Hey, from the server, I'm getting a check on the type, which is application JSON.

97
00:07:09,980 --> 00:07:17,030
So, for example, in that case, I could send back here this array with a bunch of these objects.

98
00:07:17,390 --> 00:07:25,400
And just to give you a real world test, why don't we do this, open up a new browser tab and I'm simply

99
00:07:25,400 --> 00:07:28,850
going to call the API because I think there's going to be less data.

100
00:07:28,850 --> 00:07:30,670
So there's going to be less clutter.

101
00:07:30,950 --> 00:07:37,850
So go to course, the API here and then you can either pick the slides or you can just look at the home

102
00:07:37,850 --> 00:07:38,180
page.

103
00:07:38,450 --> 00:07:46,790
And if you inspect and if you look in the browser tabs, you'll find a network and very useful one is

104
00:07:46,790 --> 00:07:51,900
this one where we can just look for all the requests we refresh and then check it out.

105
00:07:52,310 --> 00:07:58,280
So these are the requests that browser perform and I'll talk about it a bit later.

106
00:07:58,460 --> 00:08:03,140
Why there is also this style says, in fact, that's going to be one of our first examples.

107
00:08:03,440 --> 00:08:04,640
But take a look at this one.

108
00:08:04,970 --> 00:08:11,720
So I have this course API and then course and if you remember when we were building our original server,

109
00:08:12,020 --> 00:08:16,000
what I said that if we have this forward, that just means homepage.

110
00:08:16,370 --> 00:08:24,470
So if we're just navigating the course API dot com and that is our homepage, we simply add this forward.

111
00:08:24,770 --> 00:08:27,020
Now, of course, in the browser, that automatically added.

112
00:08:27,020 --> 00:08:33,080
But that's why when we're setting up the server, one of the cases is going to be if the user navigates

113
00:08:33,080 --> 00:08:35,679
to the homepage, then we simply look for.

114
00:08:36,679 --> 00:08:44,090
So if, for example, you go to the slides, you'll notice that in this case I would have to refresh

115
00:08:44,390 --> 00:08:48,740
notice here I have the course API slash slides.

116
00:08:49,070 --> 00:08:54,440
So that is already a page in my website.

117
00:08:54,440 --> 00:08:54,860
Correct.

118
00:08:54,870 --> 00:09:00,770
So I have the homepage, of course, API, and then I have the slides page where I have the slides.

119
00:09:01,100 --> 00:09:08,330
And if you take a look, if you click on it, notice all the useful data that we get over here.

120
00:09:08,630 --> 00:09:11,870
So for example, this is going to be our request.

121
00:09:11,870 --> 00:09:14,630
You are just going to be an API dot com.

122
00:09:14,810 --> 00:09:19,790
So that tells me well what the browser is trying to get, then check it out.

123
00:09:19,790 --> 00:09:23,620
The method wides get because that is default in the browser.

124
00:09:23,660 --> 00:09:27,890
Every time you open up the browser and search something, then of course you'll be performing a get

125
00:09:27,890 --> 00:09:28,280
request.

126
00:09:28,550 --> 00:09:29,260
Now check it out.

127
00:09:29,270 --> 00:09:32,150
This one, the status code, it is two hundred.

128
00:09:32,270 --> 00:09:32,660
Why?

129
00:09:32,660 --> 00:09:38,810
Because everything is successful because server send back the data, then we have this remote address

130
00:09:38,810 --> 00:09:45,050
and basically that is the IP address for my server as well as notice this call on four three.

131
00:09:45,560 --> 00:09:51,170
And we'll come back to this one when we set up our own server, because if you remember, we were always

132
00:09:51,170 --> 00:09:52,460
setting up the five thousand.

133
00:09:52,580 --> 00:09:55,100
So probably wondering, well, what is this for for three?

134
00:09:55,370 --> 00:10:01,130
And don't worry, then we'll cover that one once we set up our first server.

135
00:10:01,550 --> 00:10:07,970
And then again, we have response headers, for example, and we also have the request letters.

136
00:10:08,300 --> 00:10:13,950
So as you can see, using this network type, we can actually find a bunch of useful information.

137
00:10:14,240 --> 00:10:22,700
Now, notice here in the second set of tabs, I can see this response and preview.

138
00:10:23,000 --> 00:10:27,380
So if you take a look at the preview, this is going to be basically my site.

139
00:10:27,620 --> 00:10:29,900
And also I can see the response.

140
00:10:30,230 --> 00:10:33,080
So, as you can see, pretty much sending back the.

141
00:10:34,310 --> 00:10:41,570
So I'm sending back the website, so you go on to the browser, you request resource by default, it

142
00:10:41,570 --> 00:10:46,440
is a request and not in that body when the server sends it back.

143
00:10:46,760 --> 00:10:48,260
This is what we get back.

144
00:10:48,680 --> 00:10:50,580
So we get back to the site.

145
00:10:50,810 --> 00:10:57,870
So hopefully this gives you a clear understanding of how the HTP messages are structured.

146
00:10:58,250 --> 00:11:01,940
And now let's dive into creating our own server.

