1 00:00:00,940 --> 00:00:04,810 Now that you've seen a few sample HTTP requests using telnet, 2 00:00:04,810 --> 00:00:08,690 I'd like to show you the overall format of an HTTP request 3 00:00:08,690 --> 00:00:13,250 as stated in the specifications which I've linked to in the teacher's notes. 4 00:00:13,250 --> 00:00:15,750 Here's how an HTTP request needs to look. 5 00:00:17,150 --> 00:00:20,020 HTTP request begin with request line. 6 00:00:20,020 --> 00:00:25,000 This starts with what's called the request method, get or post. 7 00:00:25,000 --> 00:00:28,260 Know that there are other request methods available on HTTP. 8 00:00:28,260 --> 00:00:29,974 They're outside the scope of this course but 9 00:00:29,974 --> 00:00:31,743 I've linked to them in case you're curious. 10 00:00:32,750 --> 00:00:36,460 In general the get request method is used when you want to 11 00:00:36,460 --> 00:00:40,730 view a resource on the server without making any changes. 12 00:00:40,730 --> 00:00:44,710 And post request are used for actually making a change or 13 00:00:44,710 --> 00:00:46,500 update to the listed resource. 14 00:00:47,500 --> 00:00:50,480 We'll look at post request later in the course. 15 00:00:50,480 --> 00:00:54,790 Speaking of the resource, that's what's listed next, the URI, or 16 00:00:54,790 --> 00:00:58,410 again, Uniform Resource Identifier. 17 00:00:58,410 --> 00:00:59,920 If you want to view the root, or 18 00:00:59,920 --> 00:01:04,070 what's typically the home page, you'll use a single slash here. 19 00:01:04,070 --> 00:01:09,540 Finally, HTTP is listed as the protocol in use followed by a slash and 20 00:01:09,540 --> 00:01:13,480 ending with the version of HTTP, currently 1.1. 21 00:01:13,480 --> 00:01:17,090 As a side note and heads up, HTTP/2 is on the way. 22 00:01:17,090 --> 00:01:17,875 Don't worry though, 23 00:01:17,875 --> 00:01:22,510 HTTP/2 won't change any of the stuff we're discussing in this course. 24 00:01:22,510 --> 00:01:28,280 And you'll be able to continue using HTTP/1.1 likely for many years to come. 25 00:01:28,280 --> 00:01:32,111 For more info on HTTP/2, check the teacher's notes. 26 00:01:32,111 --> 00:01:35,531 The next line begins with what's called the header section of the request. 27 00:01:35,531 --> 00:01:39,780 This communicates information related to the request being made, and 28 00:01:39,780 --> 00:01:42,110 can include all sorts of info. 29 00:01:42,110 --> 00:01:45,870 In this example, you see it includes the host which we've discussed. 30 00:01:45,870 --> 00:01:49,610 The user agent which identifies the exact device making the request 31 00:01:49,610 --> 00:01:51,450 I've listed telnet here and 32 00:01:51,450 --> 00:01:56,530 accept language which tells the server which language we prefer for the response. 33 00:01:57,660 --> 00:01:59,610 There are lots of other headers available and 34 00:01:59,610 --> 00:02:01,679 we'll see a bunch more throughout the best of the course. 35 00:02:02,680 --> 00:02:04,860 Following the headers is a blank line. 36 00:02:04,860 --> 00:02:08,020 Then concluding the request, is the request body, or 37 00:02:08,020 --> 00:02:09,880 what's frequently called the payload. 38 00:02:10,900 --> 00:02:14,160 If the headers refer to the information related to the request, 39 00:02:14,160 --> 00:02:18,390 the payload refers to the data being transferred in the request, if any. 40 00:02:19,530 --> 00:02:23,210 As we'll see, data needs to be transferred when the purpose of the request 41 00:02:23,210 --> 00:02:25,660 is to change a resource on the server. 42 00:02:25,660 --> 00:02:28,950 For example, consider the scenario of using a form to 43 00:02:28,950 --> 00:02:33,700 edit the first name of a contact saved in your address book online. 44 00:02:33,700 --> 00:02:35,320 When you submit those changes, 45 00:02:35,320 --> 00:02:41,190 a post request is sent containing the new first name in the payload. 46 00:02:41,190 --> 00:02:44,450 In general, the exact changes to be made on the server 47 00:02:44,450 --> 00:02:48,440 will be contained in the payload of the post request. 48 00:02:48,440 --> 00:02:50,330 You won't see a payload in the get request. 49 00:02:51,980 --> 00:02:55,990 And there you have it, the format for any HTTP request. 50 00:02:55,990 --> 00:02:57,000 With that said, 51 00:02:57,000 --> 00:03:00,760 let's turn to the other side of this web conversation, the response.