1 00:00:00,000 --> 00:00:00,500 2 00:00:00,500 --> 00:00:02,380 BRIAN YU: Let's begin by thinking about how 3 00:00:02,380 --> 00:00:06,100 it is that computers and other devices communicate with one another 4 00:00:06,100 --> 00:00:07,180 over the internet. 5 00:00:07,180 --> 00:00:09,310 Presumably when this happens, one device is 6 00:00:09,310 --> 00:00:12,430 sending some sort of message over the internet to another device. 7 00:00:12,430 --> 00:00:15,910 And that other device is responding back with some sort of message. 8 00:00:15,910 --> 00:00:18,400 And computers and other devices all across the internet 9 00:00:18,400 --> 00:00:21,220 are performing this process, sending and receiving messages, 10 00:00:21,220 --> 00:00:24,850 whether those messages or emails or web pages or chat messages or something 11 00:00:24,850 --> 00:00:27,098 else, but how is this all happened? 12 00:00:27,098 --> 00:00:29,890 Well, it turns out that computers and other devices on the internet 13 00:00:29,890 --> 00:00:32,830 have standardized on a set of protocols some basic rules 14 00:00:32,830 --> 00:00:36,730 to follow that govern how it is that these devices should be communicating 15 00:00:36,730 --> 00:00:37,850 with one another. 16 00:00:37,850 --> 00:00:41,490 And one of these protocols is called TCP/IP. 17 00:00:41,490 --> 00:00:44,230 TCP stands for transmission control protocol, 18 00:00:44,230 --> 00:00:46,480 and IP stands for Internet Protocol. 19 00:00:46,480 --> 00:00:48,370 And these are the protocols that determine 20 00:00:48,370 --> 00:00:51,370 how it is that computers are able to communicate with one another 21 00:00:51,370 --> 00:00:52,570 over the internet. 22 00:00:52,570 --> 00:00:53,630 How does this work? 23 00:00:53,630 --> 00:00:56,740 Well, you can think of it as analogous to sending a letter in an envelope, 24 00:00:56,740 --> 00:00:57,640 for example. 25 00:00:57,640 --> 00:01:00,880 We have an envelope here that we want to send from one computer to another. 26 00:01:00,880 --> 00:01:03,940 Or you can think more physically as sending from like, one address 27 00:01:03,940 --> 00:01:04,780 to another. 28 00:01:04,780 --> 00:01:07,360 What information needs to go on that envelope for us 29 00:01:07,360 --> 00:01:09,910 to be able to know who we're sending information to 30 00:01:09,910 --> 00:01:12,550 and to make sure that envelope can get to the right place. 31 00:01:12,550 --> 00:01:16,840 Well, on a real envelope, you need the name and the address of the recipient. 32 00:01:16,840 --> 00:01:20,353 And you'll also put on the envelope the sender and the sender's address. 33 00:01:20,353 --> 00:01:23,020 And much in the same way that when you're sending physical mail, 34 00:01:23,020 --> 00:01:26,290 you include the address of the person who you want to receive the message, 35 00:01:26,290 --> 00:01:28,930 as well as the address of the person sending the message. 36 00:01:28,930 --> 00:01:32,500 On the internet it's very similar, except instead of physical addresses, 37 00:01:32,500 --> 00:01:34,480 computers and other devices on the internet 38 00:01:34,480 --> 00:01:37,690 have IP addresses-- internet protocol addresses. 39 00:01:37,690 --> 00:01:41,380 And these often take the form of some number, dot some other number, 40 00:01:41,380 --> 00:01:44,590 dot some other number, dot some other number-- four numbers separated 41 00:01:44,590 --> 00:01:45,620 by dots. 42 00:01:45,620 --> 00:01:47,950 And so you might imagine that on this digital envelope 43 00:01:47,950 --> 00:01:50,350 that we're sending from one computer on the internet 44 00:01:50,350 --> 00:01:53,620 to another computer on the internet, we might have on the face of it 45 00:01:53,620 --> 00:01:57,760 1.2.3.4, the IP address of the computer that we 46 00:01:57,760 --> 00:01:59,740 want to be receiving this message. 47 00:01:59,740 --> 00:02:03,430 And then we include our own IP address, the IP address of the sender. 48 00:02:03,430 --> 00:02:06,199 In this case, 5.6.7.8. 49 00:02:06,199 --> 00:02:08,949 Of course, this envelope contains more information than just this. 50 00:02:08,949 --> 00:02:11,230 But at minimum, it definitely needs some address 51 00:02:11,230 --> 00:02:13,630 that we're sending information to and some address 52 00:02:13,630 --> 00:02:16,000 that we're sending information from. 53 00:02:16,000 --> 00:02:20,710 These four numbers that make up the IP address, #.#.#.#, 54 00:02:20,710 --> 00:02:32,380 all range from 0 to 255, so from 0.0.0.0 to 255.255.255.255. 55 00:02:32,380 --> 00:02:36,160 And if that number 255 sounds familiar in binary, 56 00:02:36,160 --> 00:02:39,970 the number 255, as you might recall, is really just eight ones 57 00:02:39,970 --> 00:02:44,320 one after another, which means each of these numbers inside of an IP address 58 00:02:44,320 --> 00:02:48,250 is represented by eight bits of information from all eight zeros 59 00:02:48,250 --> 00:02:49,750 to all eight ones. 60 00:02:49,750 --> 00:02:50,770 There are four numbers. 61 00:02:50,770 --> 00:02:53,170 So four numbers with eight bits each means 62 00:02:53,170 --> 00:02:58,180 that in total, we have 32 bits with which to work with IP addresses. 63 00:02:58,180 --> 00:03:02,770 And if you recall, 32 bits means we can count as high as about 4 billion, 64 00:03:02,770 --> 00:03:06,010 which means there can only ever be 4 billion addresses that 65 00:03:06,010 --> 00:03:07,260 are available on the internet. 66 00:03:07,260 --> 00:03:10,210 4 billion devices that are connected to the internet that 67 00:03:10,210 --> 00:03:12,970 have addresses to which we can send information or that 68 00:03:12,970 --> 00:03:17,270 have addresses that can be the senders of information themselves. 69 00:03:17,270 --> 00:03:20,740 And while 4 billion feels like it's a pretty big number-- the number 70 00:03:20,740 --> 00:03:24,910 that you can represent using 32 bits worth of information-- in practice now 71 00:03:24,910 --> 00:03:28,240 with the internet so ubiquitous and with billions of people, many of whom 72 00:03:28,240 --> 00:03:31,755 have computers but not just computers, but also phones and other devices 73 00:03:31,755 --> 00:03:33,630 that are all connected to the internet, we're 74 00:03:33,630 --> 00:03:36,250 fast running up against this 32-bit limit. 75 00:03:36,250 --> 00:03:40,270 And it's for that reason that this notation of #.#.#.#, 76 00:03:40,270 --> 00:03:43,450 each of which is 8 bits, is known as IPv4, 77 00:03:43,450 --> 00:03:47,140 v4 of the internet protocol using 32-bit addresses, 78 00:03:47,140 --> 00:03:52,930 we now have a newer protocol called IPv6 that uses 128-bit addresses instead 79 00:03:52,930 --> 00:03:57,160 of 32-bit addresses, allowing for far, far more addresses that can be 80 00:03:57,160 --> 00:03:58,750 available on the internet. 81 00:03:58,750 --> 00:04:00,740 IPv4 is still pretty common. 82 00:04:00,740 --> 00:04:03,910 But many devices now are transitioning to IPv6, 83 00:04:03,910 --> 00:04:07,240 as the addresses that they use in order to communicate with one another 84 00:04:07,240 --> 00:04:08,710 over the internet. 85 00:04:08,710 --> 00:04:11,440 But what other information do we need in addition 86 00:04:11,440 --> 00:04:14,800 to just the address of the person that we're sending information to? 87 00:04:14,800 --> 00:04:17,980 You might imagine that if a computer has some IP address that 88 00:04:17,980 --> 00:04:21,160 allows other people to send them messages over the internet, 89 00:04:21,160 --> 00:04:24,850 that computer might be receiving a whole bunch of different types of messages. 90 00:04:24,850 --> 00:04:27,058 That computer might be receiving emails and packets 91 00:04:27,058 --> 00:04:28,600 that are traveling over the internet. 92 00:04:28,600 --> 00:04:30,820 That computer might be receiving web pages. 93 00:04:30,820 --> 00:04:33,710 It might be receiving file transfers from other devices. 94 00:04:33,710 --> 00:04:35,710 And the computer needs some way of knowing 95 00:04:35,710 --> 00:04:38,620 how to distinguish between all these different types of packets 96 00:04:38,620 --> 00:04:39,670 of information. 97 00:04:39,670 --> 00:04:42,820 Is this packet of information an email, or is this packet of information 98 00:04:42,820 --> 00:04:43,790 a web page? 99 00:04:43,790 --> 00:04:47,800 This is important relevant information that this device needs to know about. 100 00:04:47,800 --> 00:04:50,410 So in order to solve that problem, we assign 101 00:04:50,410 --> 00:04:53,020 each of the different services of information-- things, 102 00:04:53,020 --> 00:04:56,630 like email or web pages or file transfers a number. 103 00:04:56,630 --> 00:04:58,870 And that number is called a port number. 104 00:04:58,870 --> 00:05:03,670 And so some common port numbers are 21 for FTP, a file transfer protocol that 105 00:05:03,670 --> 00:05:05,950 allows you to transfer files over the internet, 106 00:05:05,950 --> 00:05:10,990 25 for SMTP commonly used for email, and 80 for HTTP, which 107 00:05:10,990 --> 00:05:13,420 you might be familiar with, which is for sending messages 108 00:05:13,420 --> 00:05:16,160 over the internet in the form of web pages, for example. 109 00:05:16,160 --> 00:05:18,790 And there are many other ports that are used as well. 110 00:05:18,790 --> 00:05:20,630 So what really goes on the envelope, then, 111 00:05:20,630 --> 00:05:23,205 is not just an IP address of the destination 112 00:05:23,205 --> 00:05:25,580 of who you want to be sending a message over the internet 113 00:05:25,580 --> 00:05:27,647 to but also a port number. 114 00:05:27,647 --> 00:05:29,230 So it might look something like this-- 115 00:05:29,230 --> 00:05:35,050 1.2.3.4 is the IP address of who it is that you want to send a message to, 116 00:05:35,050 --> 00:05:37,750 colon, and then the port number 80, in this case, 117 00:05:37,750 --> 00:05:40,360 indicating HTTP, which means we're sending a web 118 00:05:40,360 --> 00:05:44,410 page from one computer on the internet to another computer on the internet. 119 00:05:44,410 --> 00:05:47,770 But these IP addresses are not what you and I would normally 120 00:05:47,770 --> 00:05:50,830 interact with when we're typing in URLs into our web browser 121 00:05:50,830 --> 00:05:52,750 in order to try to access a web page. 122 00:05:52,750 --> 00:05:55,000 Indeed, we're not really typing IP addresses. 123 00:05:55,000 --> 00:05:57,790 You more commonly are probably typing a URL-- 124 00:05:57,790 --> 00:06:02,515 something like this-- http://www.example.com 125 00:06:02,515 --> 00:06:06,550 that tries to specify which website it is that you want to visit. 126 00:06:06,550 --> 00:06:09,880 But if we've just established that all these devices on the internet 127 00:06:09,880 --> 00:06:14,630 are identified by their IP address and not by the URL that looks like this, 128 00:06:14,630 --> 00:06:19,120 how is it that our web browser knows that when we go to www.example.com, 129 00:06:19,120 --> 00:06:22,690 what IP address should the computer be trying to connect to? 130 00:06:22,690 --> 00:06:27,160 In order to solve that, we use what's called DNS or the domain name system. 131 00:06:27,160 --> 00:06:31,450 And what DNS really is is it's really just a mapping between URLs-- 132 00:06:31,450 --> 00:06:35,110 things like google.com or harvard.edu and yale.edu 133 00:06:35,110 --> 00:06:37,630 with their corresponding IP address. 134 00:06:37,630 --> 00:06:40,720 It would be pretty annoying if every time you wanted to visit a website, 135 00:06:40,720 --> 00:06:44,200 you needed to know the IP address of the server on which that website was 136 00:06:44,200 --> 00:06:47,170 being served from in order to type in those exact numbers. 137 00:06:47,170 --> 00:06:51,250 It's much easier to remember something like harvard.edu or google.com. 138 00:06:51,250 --> 00:06:53,440 And so DNS is a bunch of servers-- 139 00:06:53,440 --> 00:06:55,870 these DNS servers that exist on the internet that 140 00:06:55,870 --> 00:07:00,340 know for any particular URL what IP address does it correspond to. 141 00:07:00,340 --> 00:07:03,520 And so when you type something like google.com into your web browser, 142 00:07:03,520 --> 00:07:05,710 your web browser can check with the DNS server 143 00:07:05,710 --> 00:07:08,770 and say, what is the IP address of google.com? 144 00:07:08,770 --> 00:07:11,300 And once it knows the IP address, then your computer 145 00:07:11,300 --> 00:07:14,200 is unable to communicate and say, let me go to google.com 146 00:07:14,200 --> 00:07:17,810 and request google.com's web page from there. 147 00:07:17,810 --> 00:07:18,880 So that's DNS. 148 00:07:18,880 --> 00:07:21,970 This way of taking these URLs and translating them 149 00:07:21,970 --> 00:07:24,370 into the corresponding IP addresses so that we 150 00:07:24,370 --> 00:07:29,185 can take a URL, like http://www.example.com 151 00:07:29,185 --> 00:07:32,230 and figure out where on the internet is the server that 152 00:07:32,230 --> 00:07:34,990 is going to serve us that web page. 153 00:07:34,990 --> 00:07:39,370 But let's now take a closer look at this first part of URL, http. 154 00:07:39,370 --> 00:07:42,280 And HTTP, as it turns out, is yet another protocol 155 00:07:42,280 --> 00:07:43,510 that exists on the internet. 156 00:07:43,510 --> 00:07:46,120 In this case standing for hypertext transfer protocol. 157 00:07:46,120 --> 00:07:49,660 Hypertext just being short for HTML or a markup language which 158 00:07:49,660 --> 00:07:51,200 we're going to see shortly. 159 00:07:51,200 --> 00:07:53,920 But what HTTP is all about really is what's 160 00:07:53,920 --> 00:07:57,610 inside of each of those envelopes that when you send an envelope from one 161 00:07:57,610 --> 00:07:59,590 device on the internet to another device, 162 00:07:59,590 --> 00:08:02,890 sure, on the outside it's labeled by the IP address of the person 163 00:08:02,890 --> 00:08:06,580 you're trying to communicate with and your own IP address of the sender. 164 00:08:06,580 --> 00:08:08,270 But what's inside of the envelope? 165 00:08:08,270 --> 00:08:11,410 What is the content of my request to a web server when 166 00:08:11,410 --> 00:08:12,910 I'm trying to get a web page? 167 00:08:12,910 --> 00:08:14,860 And what is the content of that response that 168 00:08:14,860 --> 00:08:18,850 comes back when I am trying to get information back from a particular web 169 00:08:18,850 --> 00:08:19,900 server? 170 00:08:19,900 --> 00:08:23,470 Well, when I make a request, it might look a little something like this. 171 00:08:23,470 --> 00:08:25,810 So inside of that envelope, we might see content 172 00:08:25,810 --> 00:08:28,990 like this where the first word you see here is GET. 173 00:08:28,990 --> 00:08:30,850 This is what we call a request method. 174 00:08:30,850 --> 00:08:34,390 And in this case it just means I'm trying to get a web page. 175 00:08:34,390 --> 00:08:36,130 Next up is this slash. 176 00:08:36,130 --> 00:08:39,970 And the second part of specifying what particular resource on the web page 177 00:08:39,970 --> 00:08:42,549 that I'm trying to connect to, do I want to get back? 178 00:08:42,549 --> 00:08:45,010 And so many websites, like google.com, for example, 179 00:08:45,010 --> 00:08:49,360 have a /search or a /settings or any number of other pages that I might want 180 00:08:49,360 --> 00:08:50,350 to try to access. 181 00:08:50,350 --> 00:08:52,820 Some may also have images that I might want to get. 182 00:08:52,820 --> 00:08:54,940 And so this slash in this case is specifying 183 00:08:54,940 --> 00:08:57,130 that I just want the root of the website-- whatever 184 00:08:57,130 --> 00:09:01,360 I would get to if I went to in this case, www.example.com. 185 00:09:01,360 --> 00:09:06,130 But as you might imagine, I might go to www.example.com/ something else to get 186 00:09:06,130 --> 00:09:07,420 a particular page. 187 00:09:07,420 --> 00:09:10,210 And that would go in the second parameter here. 188 00:09:10,210 --> 00:09:13,550 Following that is HTTP/1.1. 189 00:09:13,550 --> 00:09:16,600 This is specifying which version of the HTTP protocol 190 00:09:16,600 --> 00:09:19,390 that I'm using in order to communicate with this host. 191 00:09:19,390 --> 00:09:22,360 In this case, I'm using version 1.1, which is quite common. 192 00:09:22,360 --> 00:09:24,580 Nowadays version two is also pretty common. 193 00:09:24,580 --> 00:09:28,270 But you'll still see HTTP version 1.1 around quite a bit. 194 00:09:28,270 --> 00:09:30,520 And beneath that I'm connecting to a particular host-- 195 00:09:30,520 --> 00:09:33,730 something like www.example.com example as the host 196 00:09:33,730 --> 00:09:35,140 that I want to communicate with. 197 00:09:35,140 --> 00:09:37,840 It's possible that the web server that I'm communicating with 198 00:09:37,840 --> 00:09:40,210 is actually holding multiple hosts altogether 199 00:09:40,210 --> 00:09:41,710 and is balancing between them. 200 00:09:41,710 --> 00:09:45,620 And so in my request, I need to specify what host do I want to connect to? 201 00:09:45,620 --> 00:09:48,250 In this case, www.example.com. 202 00:09:48,250 --> 00:09:51,370 And there's more information that comes in the request other than that. 203 00:09:51,370 --> 00:09:53,140 But the key ideas here is that I am trying 204 00:09:53,140 --> 00:09:55,630 to get a page from a particular host. 205 00:09:55,630 --> 00:09:59,980 I specify what page it is that I want to access in addition to specifying 206 00:09:59,980 --> 00:10:04,030 which version of the HTTP protocol I'm using in order to try and make 207 00:10:04,030 --> 00:10:06,850 this request to the website. 208 00:10:06,850 --> 00:10:12,160 What then responds back to me when www.example.com receives my request 209 00:10:12,160 --> 00:10:14,590 and wants to send something back to me the person who 210 00:10:14,590 --> 00:10:16,780 requested this page in the first place, well, 211 00:10:16,780 --> 00:10:19,670 the response might look something like this. 212 00:10:19,670 --> 00:10:24,790 Again, starting with HTTP/1.1, the version of the HTTP protocol that is 213 00:10:24,790 --> 00:10:27,580 being used in order to communicate information. 214 00:10:27,580 --> 00:10:30,070 Next up is this number 200. 215 00:10:30,070 --> 00:10:32,470 This is what we would call a status code. 216 00:10:32,470 --> 00:10:35,470 Every time HTTP gives you a response, it's 217 00:10:35,470 --> 00:10:38,110 going to come along with some code that specifies 218 00:10:38,110 --> 00:10:40,150 how the response was resolved. 219 00:10:40,150 --> 00:10:42,970 And 200 just means as the word immediately following it 220 00:10:42,970 --> 00:10:44,950 would describe everything was OK. 221 00:10:44,950 --> 00:10:48,610 We were able to successfully give you back some sort of response. 222 00:10:48,610 --> 00:10:50,560 What type of response came back? 223 00:10:50,560 --> 00:10:52,960 Well, that comes on the second line of the response. 224 00:10:52,960 --> 00:10:58,120 Content type colon: text/html means the response that came back to me 225 00:10:58,120 --> 00:11:01,180 is some HTML, some markup that's ultimately 226 00:11:01,180 --> 00:11:02,980 going to represent a web page. 227 00:11:02,980 --> 00:11:05,297 But more on HTML in just a moment. 228 00:11:05,297 --> 00:11:07,880 The response has more information again than just that, likely 229 00:11:07,880 --> 00:11:10,960 the actual content of the HTML that's coming back to me. 230 00:11:10,960 --> 00:11:13,300 But in short, this response is specifying 231 00:11:13,300 --> 00:11:17,090 the version of the HTTP protocol, the status code that came back, 232 00:11:17,090 --> 00:11:21,100 200, meaning OK, and then the content type-- what type of information 233 00:11:21,100 --> 00:11:22,150 is coming back to me. 234 00:11:22,150 --> 00:11:23,650 In this case, it was HTML. 235 00:11:23,650 --> 00:11:26,020 But it very well might have been a text file or an image 236 00:11:26,020 --> 00:11:30,040 or any other information that might have been transferred over the internet. 237 00:11:30,040 --> 00:11:34,110 This status code 200, meaning OK maybe isn't something you've seen before. 238 00:11:34,110 --> 00:11:35,860 But certainly if you've used the internet, 239 00:11:35,860 --> 00:11:38,830 there are other status codes that you're probably more familiar with. 240 00:11:38,830 --> 00:11:43,750 For example, 404 might be pretty common which means not found. 241 00:11:43,750 --> 00:11:46,450 If you try to request a page that just isn't there, 242 00:11:46,450 --> 00:11:51,130 HTTP says that the server is going to respond with a status code of 404, 243 00:11:51,130 --> 00:11:52,392 meaning that it wasn't found. 244 00:11:52,392 --> 00:11:54,100 And there are other status codes as well. 245 00:11:54,100 --> 00:11:57,430 Status codes, like 301 which means move permanently. 246 00:11:57,430 --> 00:11:59,420 In other words, this page has moved somewhere. 247 00:11:59,420 --> 00:12:01,570 And so you'll often be redirected from one page 248 00:12:01,570 --> 00:12:04,870 to another page when you receive a status code of 301. 249 00:12:04,870 --> 00:12:06,960 403 is a status code meaning forbidden. 250 00:12:06,960 --> 00:12:10,210 For example, if you try to access a page that you don't have permission to see 251 00:12:10,210 --> 00:12:12,310 or that you need to log in to see first, you'll 252 00:12:12,310 --> 00:12:14,980 very often see a status code of 403, meaning 253 00:12:14,980 --> 00:12:19,300 you don't have permission to be able to see this particular resource. 254 00:12:19,300 --> 00:12:22,990 And status code 500 generally means an internal server error. 255 00:12:22,990 --> 00:12:25,900 Whoever programmed the server that is accepting these requests 256 00:12:25,900 --> 00:12:28,780 and responding with information likely has a bug in their code, 257 00:12:28,780 --> 00:12:31,760 for example, that might result in an error that occurs. 258 00:12:31,760 --> 00:12:34,877 And so that's when a status code of 500 gets responded as well. 259 00:12:34,877 --> 00:12:36,460 And there are many other status codes. 260 00:12:36,460 --> 00:12:38,502 But these are just some of the more popular ones. 261 00:12:38,502 --> 00:12:42,550 And status code 200 is what comes back all the time when you request a page, 262 00:12:42,550 --> 00:12:44,410 and you're able to view it successfully. 263 00:12:44,410 --> 00:12:47,412 The web browser usually doesn't show you the status code number 200 264 00:12:47,412 --> 00:12:49,870 just because everything went well, so there wasn't a reason 265 00:12:49,870 --> 00:12:51,400 to show you anything in addition. 266 00:12:51,400 --> 00:12:53,650 But as we'll see in just a moment, we can take a look 267 00:12:53,650 --> 00:12:55,720 at what's actually happening in the network-- 268 00:12:55,720 --> 00:12:57,250 what messages are being sent-- 269 00:12:57,250 --> 00:12:58,890 what responses are coming back. 270 00:12:58,890 --> 00:13:02,620 And in those responses, we'll often see a status code of 200 271 00:13:02,620 --> 00:13:06,550 which will indicate to us that everything was indeed OK. 272 00:13:06,550 --> 00:13:08,800 So let's take a look at a real example and actually 273 00:13:08,800 --> 00:13:10,930 try to open up a web browser and see what 274 00:13:10,930 --> 00:13:14,080 happens when we make a web request when we type in a URL 275 00:13:14,080 --> 00:13:16,382 and try and visit a web page. 276 00:13:16,382 --> 00:13:19,090 I'll go ahead and open up Google Chrome, although this feature is 277 00:13:19,090 --> 00:13:21,230 available in other web browsers as well. 278 00:13:21,230 --> 00:13:23,050 I'll go up into the View menu. 279 00:13:23,050 --> 00:13:26,520 And I'll go to Developer and then Developer Tools. 280 00:13:26,520 --> 00:13:28,270 And then over here on the right-hand side, 281 00:13:28,270 --> 00:13:31,720 I'm going to go to the Network tab, which is going to allow me to monitor 282 00:13:31,720 --> 00:13:33,530 all of the network traffic-- 283 00:13:33,530 --> 00:13:37,120 all of the requests and responses that are coming from my web browser 284 00:13:37,120 --> 00:13:39,880 and being sent back to my web browser. 285 00:13:39,880 --> 00:13:41,050 So we go to the URL bar. 286 00:13:41,050 --> 00:13:44,620 And let me just visit a website, like google.com, for example. 287 00:13:44,620 --> 00:13:48,290 And we'll take a look at what happens after this web page loads. 288 00:13:48,290 --> 00:13:50,440 All right, so once google.com loads, you'll 289 00:13:50,440 --> 00:13:53,202 notice here in the Network tab a lot of things have shown up. 290 00:13:53,202 --> 00:13:56,160 But I'm going to ignore most of that and just scroll up to the very top 291 00:13:56,160 --> 00:13:59,200 where I'll notice that I had an initial request for google.com which 292 00:13:59,200 --> 00:14:00,550 is what I typed in. 293 00:14:00,550 --> 00:14:04,000 And I'll click on that just to take a look at some more details. 294 00:14:04,000 --> 00:14:05,270 Here I see the headers. 295 00:14:05,270 --> 00:14:09,040 And if I scroll down, I can take a look at the Request Headers, which 296 00:14:09,040 --> 00:14:11,620 was the information that I sent to Google's servers 297 00:14:11,620 --> 00:14:13,660 when I tried to request this web page. 298 00:14:13,660 --> 00:14:16,330 And I can also see above that the Response Headers, 299 00:14:16,330 --> 00:14:18,460 the information that came back to me when 300 00:14:18,460 --> 00:14:20,810 Google responded with this web page. 301 00:14:20,810 --> 00:14:23,230 I'll go ahead and click the View Source button here just 302 00:14:23,230 --> 00:14:25,060 to see what was inside of this request. 303 00:14:25,060 --> 00:14:29,680 And you'll notice right here we see HTTP/1.1, 304 00:14:29,680 --> 00:14:32,710 meaning version 1.1 of the HTTP protocol. 305 00:14:32,710 --> 00:14:35,290 And the response code that seems to have come back to me 306 00:14:35,290 --> 00:14:39,190 is 301, move permanently-- one we've seen before that means 307 00:14:39,190 --> 00:14:41,710 I've been redirected to somewhere else. 308 00:14:41,710 --> 00:14:44,020 Well, I typed in google.com. 309 00:14:44,020 --> 00:14:46,415 So where have I been redirected to? 310 00:14:46,415 --> 00:14:48,790 Well, if we look immediately below it on the second line, 311 00:14:48,790 --> 00:14:55,090 we see location: and then http://www.google.com. 312 00:14:55,090 --> 00:14:57,610 So it seems that whenever I try to visit google.com, 313 00:14:57,610 --> 00:15:01,950 Google is redirecting me to www.google.com instead. 314 00:15:01,950 --> 00:15:06,230 And this is a fairly common convention where www stands for worldwide web. 315 00:15:06,230 --> 00:15:08,480 And many web applications are hosting their website 316 00:15:08,480 --> 00:15:13,550 on www.something, for example, although strictly speaking, that isn't required. 317 00:15:13,550 --> 00:15:16,630 So I've been redirected to www.google.com. 318 00:15:16,630 --> 00:15:19,940 And we can see that here I have www.google.com. 319 00:15:19,940 --> 00:15:22,250 This was the next request that my web browser 320 00:15:22,250 --> 00:15:25,040 made because it saw that I'd been redirected somewhere else. 321 00:15:25,040 --> 00:15:28,760 Here, 307, Internal Redirect just means I've been redirected again. 322 00:15:28,760 --> 00:15:30,680 Where have I been redirected to? 323 00:15:30,680 --> 00:15:38,210 Well, it looks like here, I've been redirected to https://www.google.com. 324 00:15:38,210 --> 00:15:41,420 So https, the s standing for secure, just 325 00:15:41,420 --> 00:15:44,120 means that Google wants me to connect to their website securely. 326 00:15:44,120 --> 00:15:45,940 And indeed, more and more websites nowadays 327 00:15:45,940 --> 00:15:48,980 are using https, a version of the protocol that 328 00:15:48,980 --> 00:15:51,980 allows for information to be encrypted when it's transferred between one 329 00:15:51,980 --> 00:15:54,680 computer and another over the internet just to make sure 330 00:15:54,680 --> 00:15:57,270 that that connection is more secure. 331 00:15:57,270 --> 00:15:59,940 And so now, I'll go to the next request that my computer made. 332 00:15:59,940 --> 00:16:07,160 Here, the URL that I was requesting is now https://www.google.com. 333 00:16:07,160 --> 00:16:12,020 And now, finally, the status code is 200, meaning everything was OK. 334 00:16:12,020 --> 00:16:13,160 So what happened here? 335 00:16:13,160 --> 00:16:15,470 I typed google.com into my web browser. 336 00:16:15,470 --> 00:16:18,980 And I got a 301 response code, meaning that I'd been redirected 337 00:16:18,980 --> 00:16:21,920 to somewhere else, www.google.com. 338 00:16:21,920 --> 00:16:24,498 When I went there, I made a request to that URL 339 00:16:24,498 --> 00:16:26,540 and got another response, which was that I'd been 340 00:16:26,540 --> 00:16:31,850 redirected to https://www.google.com. 341 00:16:31,850 --> 00:16:35,210 And when I made a request to that URL, now and only now 342 00:16:35,210 --> 00:16:39,287 do I see that I get a status code of 200 meaning that everything was OK. 343 00:16:39,287 --> 00:16:41,120 And a lot of other resources have come back, 344 00:16:41,120 --> 00:16:43,130 as well, so when you load Google's web page, 345 00:16:43,130 --> 00:16:46,310 it's likely loading other scripts or other images or other fonts, 346 00:16:46,310 --> 00:16:49,670 for example, that all need to be loaded in order to display this web page. 347 00:16:49,670 --> 00:16:53,000 But the key here is that anytime you make a request over the internet, 348 00:16:53,000 --> 00:16:55,730 it's using this HTTP protocol that allows me 349 00:16:55,730 --> 00:16:58,040 to make a request to a particular URL. 350 00:16:58,040 --> 00:17:00,140 And when the response comes back, I can actually 351 00:17:00,140 --> 00:17:02,510 see what's going on using the Network tab of Google 352 00:17:02,510 --> 00:17:04,910 Chrome or similar features for other web browsers 353 00:17:04,910 --> 00:17:08,420 that you might be using in order to get an understanding for what exactly 354 00:17:08,420 --> 00:17:10,702 is coming back from this web server. 355 00:17:10,702 --> 00:17:12,619 And as we'll see later on in this track, we'll 356 00:17:12,619 --> 00:17:14,750 start to build web applications of our own 357 00:17:14,750 --> 00:17:17,180 where we're writing these web servers and deciding 358 00:17:17,180 --> 00:17:18,920 what status code should be returned? 359 00:17:18,920 --> 00:17:21,500 What is the content that should be returned back to the user? 360 00:17:21,500 --> 00:17:24,109 When they make a request to slash or to slash something 361 00:17:24,109 --> 00:17:28,280 else or to any other page that might exist on our web application. 362 00:17:28,280 --> 00:17:30,410 So ultimately, there are a lot of protocols 363 00:17:30,410 --> 00:17:33,260 at play here in determining how it is that devices on the internet, 364 00:17:33,260 --> 00:17:35,510 be that your computer or phones or tablets 365 00:17:35,510 --> 00:17:38,510 are able to communicate with other devices on the internet. 366 00:17:38,510 --> 00:17:41,690 We saw a TCP and IP, a transmission control protocol 367 00:17:41,690 --> 00:17:44,090 and the internet protocol that are determining things 368 00:17:44,090 --> 00:17:46,730 like how it is that information is sent from one device 369 00:17:46,730 --> 00:17:50,060 to another-- what goes on the outside of that envelope-- things 370 00:17:50,060 --> 00:17:53,240 like the IP address, the address of who it is that you're trying to send 371 00:17:53,240 --> 00:17:57,260 information to in addition to the port number that determines what kind 372 00:17:57,260 --> 00:18:01,040 of service you're trying to communicate, whether that be an email address 373 00:18:01,040 --> 00:18:03,410 or whether that be a web page or whether that's a file 374 00:18:03,410 --> 00:18:06,380 that you're trying to send from one person to another person. 375 00:18:06,380 --> 00:18:09,797 And then we saw HTTP, the hypertext transfer protocol, 376 00:18:09,797 --> 00:18:11,630 which is the protocol that determines what's 377 00:18:11,630 --> 00:18:13,650 actually inside of that envelope. 378 00:18:13,650 --> 00:18:16,460 What is the information that I am sending to a web server 379 00:18:16,460 --> 00:18:18,480 when I'm trying to request a web page? 380 00:18:18,480 --> 00:18:20,720 And then what comes back to me in that response-- 381 00:18:20,720 --> 00:18:23,220 the version of the protocol, the status code, 382 00:18:23,220 --> 00:18:26,030 and then the actual content of what comes back to me. 383 00:18:26,030 --> 00:18:28,220 So next, we'll take a look at that actual content 384 00:18:28,220 --> 00:18:30,290 and take a look at how to build web pages that 385 00:18:30,290 --> 00:18:33,260 can be sent using the HTTP protocol and ultimately 386 00:18:33,260 --> 00:18:36,370 viewed inside of your web browser. 387 00:18:36,370 --> 00:18:37,000