1 00:00:00,527 --> 00:00:04,136 You've already seen some HTTP responses, but 2 00:00:04,136 --> 00:00:09,105 let me pull one up just to refresh, so telnet httpbin.org 80. 3 00:00:09,105 --> 00:00:13,989 And I'll GET the resource /xml using HTTP 4 00:00:13,989 --> 00:00:18,880 version 1.1 at the HOST httpbin.org. 5 00:00:18,880 --> 00:00:23,489 Upon making this request, what comes up soon thereafter is the response. 6 00:00:23,489 --> 00:00:29,279 This HTTP response is formatted in mostly the same way, so let's check it out. 7 00:00:29,279 --> 00:00:33,729 The first line is the status line, which starts out exactly the way the request 8 00:00:33,729 --> 00:00:37,924 line ended, with http/ then the version number, currently, 1.1. 9 00:00:37,924 --> 00:00:43,228 Then comes the response code, then a space, then the status message. 10 00:00:43,228 --> 00:00:47,416 We could spend an entire course talking about response codes and 11 00:00:47,416 --> 00:00:49,906 messages but this is not that course. 12 00:00:49,906 --> 00:00:54,498 Some that you should be familiar with are 200 level codes which, in general, 13 00:00:54,498 --> 00:00:55,858 are success messages. 14 00:00:55,858 --> 00:01:02,024 Particularly the response code 200 which is a message meaning okay. 15 00:01:02,024 --> 00:01:07,393 Another you've seen is 404, which has the message not found. 16 00:01:07,393 --> 00:01:10,556 Other 400 level codes, in general, 17 00:01:10,556 --> 00:01:15,404 refer to something that went wrong in the client's request. 18 00:01:15,404 --> 00:01:18,233 You also may see a response code in the 300s, 19 00:01:18,233 --> 00:01:21,926 which indicates that the resource requested may have moved. 20 00:01:21,926 --> 00:01:26,861 But in any case, the rest of the response contains instructions about where to 21 00:01:26,861 --> 00:01:29,345 go next, that is, where to redirect. 22 00:01:29,345 --> 00:01:33,133 Finally, there are 500 level error codes, which is used for 23 00:01:33,133 --> 00:01:38,059 indicating that something went wrong on the server while processing the request. 24 00:01:38,059 --> 00:01:43,536 Remember, a 500 level code means that something went wrong on the server. 25 00:01:43,536 --> 00:01:48,028 Moving on, following the status line is a section of headers. 26 00:01:48,028 --> 00:01:52,810 This section is formatted in the same way as request headers, with a header name, 27 00:01:52,810 --> 00:01:56,573 then a colon and a space, followed by the value for that header. 28 00:01:56,573 --> 00:02:01,042 These headers communicate information about the response, metadata, so to speak. 29 00:02:01,042 --> 00:02:05,840 In our example, the headers include the type of server handling the request, 30 00:02:05,840 --> 00:02:07,088 nginx in this case. 31 00:02:07,088 --> 00:02:10,141 The exact date and time the response was went and 32 00:02:10,141 --> 00:02:15,036 the type of content that's included in the body below, in this case, XML. 33 00:02:15,036 --> 00:02:21,002 When the response includes HTML you'll see a content type of text/HTML. 34 00:02:21,002 --> 00:02:25,694 Following the list of headers is a blank line, and then comes the response body, 35 00:02:25,694 --> 00:02:27,704 which is also called the payload. 36 00:02:27,704 --> 00:02:31,660 In this case, we made a request to the XML resource, so 37 00:02:31,660 --> 00:02:36,226 the response body or payload is the actual XML that comes back. 38 00:02:36,226 --> 00:02:41,005 If we had requested HTML, the payload would contain the HTML that comes back. 39 00:02:42,414 --> 00:02:46,655 Now that you've seen the general format of HTTP, there's one point I'd like 40 00:02:46,655 --> 00:02:50,460 to drive home in this request response cycle of an HTTP conversation. 41 00:02:50,460 --> 00:02:56,754 And that is that HTTP itself is what's called a stateless protocol. 42 00:02:56,754 --> 00:03:01,101 Stateless means that there's no record of previous interactions, and 43 00:03:01,101 --> 00:03:03,809 each interaction is processed with only with 44 00:03:03,809 --> 00:03:07,670 the information that comes with that particular interaction. 45 00:03:07,670 --> 00:03:13,195 Put it in different way, that means that there is nothing inherent to HTTP that 46 00:03:13,195 --> 00:03:18,318 allows it to remember a previous request and use it to inform a later one. 47 00:03:18,318 --> 00:03:22,346 When a web application appears as if it remembers a previous request, 48 00:03:22,346 --> 00:03:25,897 like remembering your user name when you return to Facebook, 49 00:03:25,897 --> 00:03:29,676 this is a feature that's part of an application that using HTTP. 50 00:03:29,676 --> 00:03:33,487 But not part of HTTP itself. 51 00:03:33,487 --> 00:03:38,264 HTTP messages are like self-destructing notes that disappear after they're read. 52 00:03:38,264 --> 00:03:41,345 Okay, you get it, HTTP is stateless.