1 00:00:06,770 --> 00:00:08,740 So most every day, you probably type or 2 00:00:08,740 --> 00:00:10,760 at least see HTTP. 3 00:00:10,760 --> 00:00:12,850 In fact, if you're watching or listening to this over the 4 00:00:12,850 --> 00:00:15,220 web, you're using HTTP right now. 5 00:00:15,220 --> 00:00:16,160 But what is it? 6 00:00:16,160 --> 00:00:18,620 Well, it's what you type at the start of a URL, or at 7 00:00:18,620 --> 00:00:19,400 least used to. 8 00:00:19,400 --> 00:00:22,250 These days, browsers just assume that you want HTTP, 9 00:00:22,250 --> 00:00:24,190 even if you don't actually type it. 10 00:00:24,190 --> 00:00:27,830 More technically though, HTTP is a protocol, a language of 11 00:00:27,830 --> 00:00:30,690 sorts, that web browsers and web servers speak, a set of 12 00:00:30,690 --> 00:00:32,409 conventions to which they adhere, just 13 00:00:32,409 --> 00:00:33,710 like we humans have. 14 00:00:33,710 --> 00:00:36,090 For instance, in the US, when you first meet someone, you 15 00:00:36,090 --> 00:00:38,440 typically initiate a connection by extending your 16 00:00:38,440 --> 00:00:41,050 hand, at which point, the other person responds to it by 17 00:00:41,050 --> 00:00:41,830 shaking it. 18 00:00:41,830 --> 00:00:43,070 Well, that's a protocol. 19 00:00:43,070 --> 00:00:45,680 In some countries or families, you initiate a connection by 20 00:00:45,680 --> 00:00:47,060 kissing someone on the cheek. 21 00:00:47,060 --> 00:00:48,670 Well, that another protocol. 22 00:00:48,670 --> 00:00:52,160 So HTTP is a protocol that happens to involve computers 23 00:00:52,160 --> 00:00:53,160 instead of humans. 24 00:00:53,160 --> 00:00:54,350 And here's how it works. 25 00:00:54,350 --> 00:00:57,390 When a browser wants to show a human a web page, it initiates 26 00:00:57,390 --> 00:01:01,330 a connection to a web server by sending an HTTP request, 27 00:01:01,330 --> 00:01:03,710 inside of which is a message akin to please 28 00:01:03,710 --> 00:01:05,080 send me this web page. 29 00:01:05,080 --> 00:01:06,790 In reality, it's something more cryptic like, 30 00:01:06,790 --> 00:01:08,040 get/http/1.1. 31 00:01:10,200 --> 00:01:13,220 But when the server receives that request, it sends an HTTP 32 00:01:13,220 --> 00:01:15,750 response, inside of which is the web page. 33 00:01:15,750 --> 00:01:17,960 Now that web page, meanwhile, is written in a language 34 00:01:17,960 --> 00:01:21,560 called HTML, or HyperText Markup Language. 35 00:01:21,560 --> 00:01:24,050 And that's HTTP gets its own name. 36 00:01:24,050 --> 00:01:27,840 HTTP is an acronym for HyperText Transfer Protocol, 37 00:01:27,840 --> 00:01:30,180 because what it's transferring from server to browser is 38 00:01:30,180 --> 00:01:32,870 hypertext, HyperText Markup Language. 39 00:01:32,870 --> 00:01:35,550 In a sense, the web is like a restaurants where you're the 40 00:01:35,550 --> 00:01:37,010 customer or the client. 41 00:01:37,010 --> 00:01:39,370 Much like you order food in a restaurant from a waiter or 42 00:01:39,370 --> 00:01:42,360 waitress who then brings it to your table, so do web browsers 43 00:01:42,360 --> 00:01:44,510 order files from a web server who then 44 00:01:44,510 --> 00:01:45,910 returns with the same. 45 00:01:45,910 --> 00:01:48,230 In fact, is for this very reason that browsers are often 46 00:01:48,230 --> 00:01:50,985 called clients and servers are called, well servers. 47 00:01:50,985 --> 00:01:53,790 The relationship is very much the same. 48 00:01:53,790 --> 00:01:55,010 Make sense? 49 00:01:55,010 --> 00:01:57,750 All right, well let's take a look at an actual HTTP request 50 00:01:57,750 --> 00:01:58,760 and response. 51 00:01:58,760 --> 00:02:00,230 First, let's open a browser. 52 00:02:00,230 --> 00:02:02,320 I happen to be using Chrome, but you do this in most any 53 00:02:02,320 --> 00:02:03,740 browser these days. 54 00:02:03,740 --> 00:02:06,790 Let's next select View, Developer, Developer Tools, 55 00:02:06,790 --> 00:02:08,259 which will open a Developer panel at the 56 00:02:08,259 --> 00:02:09,550 bottom of our window. 57 00:02:09,550 --> 00:02:12,450 And let's next click that panel's Network tab. 58 00:02:12,450 --> 00:02:14,750 The next time I load web page from a server, we'll see in 59 00:02:14,750 --> 00:02:17,300 this tab all of the HTTP traffic between 60 00:02:17,300 --> 00:02:19,150 Chrome and the server. 61 00:02:19,150 --> 00:02:19,490 OK. 62 00:02:19,490 --> 00:02:20,936 Let's visit, say, Google. 63 00:02:20,936 --> 00:02:27,580 http://www.google.com/enter. 64 00:02:27,580 --> 00:02:28,990 OK, what just happened? 65 00:02:28,990 --> 00:02:31,240 Well first, let's scroll to the very top of the tab. 66 00:02:31,240 --> 00:02:34,270 The very first row represents Google's HTTP response to my 67 00:02:34,270 --> 00:02:35,670 HTTP request. 68 00:02:35,670 --> 00:02:37,000 Well, let's click that row. 69 00:02:37,000 --> 00:02:39,460 To the right, we now see a preview of the HTML that was 70 00:02:39,460 --> 00:02:41,680 included in that response, along with a whole bunch of 71 00:02:41,680 --> 00:02:42,390 JavaScript. 72 00:02:42,390 --> 00:02:44,590 But more on those another time. 73 00:02:44,590 --> 00:02:46,810 Let's now click the Headers tab to the left of this 74 00:02:46,810 --> 00:02:50,030 Preview tab, and here's where we can see the actual HTTP 75 00:02:50,030 --> 00:02:53,650 request that my browser sent and the actual HTTP response 76 00:02:53,650 --> 00:02:54,900 that Google returned. 77 00:02:54,900 --> 00:02:57,450 As for the server's response, let's click View Source next 78 00:02:57,450 --> 00:02:58,670 Response Headers. 79 00:02:58,670 --> 00:03:00,330 Here's what Google sent to my browser. 80 00:03:00,330 --> 00:03:02,500 The first line is perhaps the most interesting-- 81 00:03:02,500 --> 00:03:06,790 HTTP/1.1 200 OK. 82 00:03:06,790 --> 00:03:09,060 This means all is well and the homepage was transferred 83 00:03:09,060 --> 00:03:10,580 successfully. 84 00:03:10,580 --> 00:03:13,010 Odds are you've never seen this 200 before, otherwise 85 00:03:13,010 --> 00:03:17,520 known as an HTTP status code, but you've probably seen 404, 86 00:03:17,520 --> 00:03:19,430 File Not Found, maybe some others. 87 00:03:19,430 --> 00:03:21,570 Well, this is where those numbers come from. 88 00:03:21,570 --> 00:03:22,770 Well there you have it-- 89 00:03:22,770 --> 00:03:24,020 HTTP.