1 00:00:00,750 --> 00:00:03,170 Now that we've seen some basic get requests and 2 00:00:03,170 --> 00:00:08,860 subsequent responses, let's check out how to send data with an HTTP request. 3 00:00:08,860 --> 00:00:13,850 So far, we've simply made requests to view certain resources, and these requests 4 00:00:13,850 --> 00:00:19,850 haven't required us to supply additional data related to actual resource requested. 5 00:00:19,850 --> 00:00:23,850 Even more, we have yet to send a post request which is used 6 00:00:23,850 --> 00:00:27,930 to find the resource requested according to the data included in the request body. 7 00:00:29,470 --> 00:00:31,680 Let's take a peek at both of those scenarios now. 8 00:00:33,980 --> 00:00:36,530 In the first scenario, we'll consider using a get 9 00:00:36,530 --> 00:00:41,000 request to supply additional data related to the resource we're requesting. 10 00:00:41,000 --> 00:00:45,130 Let's continue using httpbin.org for our examples. 11 00:00:45,130 --> 00:00:49,510 In a get request, you can pass data to the server via the URI and the request line. 12 00:00:49,510 --> 00:00:51,600 Let me show you an example. 13 00:00:51,600 --> 00:00:56,510 All right, we'll telnet to httpbin.org using port 80. 14 00:00:56,510 --> 00:01:00,670 And I will make a get request to the resource name /get and 15 00:01:00,670 --> 00:01:06,056 let me throw some data in here and explain to you in a moment what I am doing. 16 00:01:14,873 --> 00:01:17,120 Let me hit enter twice. 17 00:01:17,120 --> 00:01:18,440 Great. 18 00:01:18,440 --> 00:01:20,630 Scroll up to my initial request. 19 00:01:20,630 --> 00:01:26,650 Now in this example, I'm requesting the resource at /get, 20 00:01:26,650 --> 00:01:33,870 passing a first name and a language in the form of a query string. 21 00:01:33,870 --> 00:01:37,620 A query string is simply a sequence of name value pairs where the names and 22 00:01:37,620 --> 00:01:41,360 values are separated by an equal sign here and 23 00:01:41,360 --> 00:01:45,950 here and the pairs are separated by ampersands. 24 00:01:45,950 --> 00:01:51,070 So we have one ampersand between the two name value pairs. 25 00:01:51,070 --> 00:01:56,811 When using a query string and a uri, you start with a single question mark. 26 00:01:56,811 --> 00:02:00,922 When I make this request, I can see that the server was able to read the data I 27 00:02:00,922 --> 00:02:03,542 passed, and use it to put together a response. 28 00:02:03,542 --> 00:02:07,413 If I scroll down I see there is the first name that I passed and 29 00:02:07,413 --> 00:02:10,310 there is the language that I passed. 30 00:02:10,310 --> 00:02:14,750 In this case, HTTP bin gave me a response in JSON format. 31 00:02:14,750 --> 00:02:17,770 JSON stands for JavaScript object notation, and 32 00:02:17,770 --> 00:02:21,600 is a widely used data format, used frequently in web applications because, 33 00:02:21,600 --> 00:02:24,350 well, JavaScript can directly read the data. 34 00:02:24,350 --> 00:02:27,250 This kind of data transmission in a get request 35 00:02:27,250 --> 00:02:30,480 only helps the server put together an accurate response. 36 00:02:30,480 --> 00:02:35,240 It should not actually change anything on the server related to the resource. 37 00:02:35,240 --> 00:02:37,530 I can demonstrate this again by making a new request. 38 00:02:37,530 --> 00:02:43,280 Let me clear my screen, I'll telnet to httpbin.org at port 80. 39 00:02:43,280 --> 00:02:45,985 And let me pass it some different data. 40 00:02:45,985 --> 00:02:53,310 /get is the resource that I'm requesting, and I'll pass it a company and a city. 41 00:02:56,452 --> 00:02:58,459 HTTP version 1.1. 42 00:02:58,459 --> 00:03:03,930 And the host is again httpbin.org. 43 00:03:03,930 --> 00:03:06,930 And there I see the company that I sent in the request 44 00:03:06,930 --> 00:03:09,560 as well as the city that I sent in the request. 45 00:03:09,560 --> 00:03:14,389 One other thing worth pointing out here is the content link header in the response. 46 00:03:15,400 --> 00:03:20,030 Whenever there is data in a response body, a content length header will be present 47 00:03:20,030 --> 00:03:24,000 indicating the length or the size of the response in bytes. 48 00:03:24,000 --> 00:03:30,180 What this means in our case is that the size of the response body is 217 bytes. 49 00:03:31,610 --> 00:03:35,980 Using get request to send data is often used in a web forum to search a website. 50 00:03:35,980 --> 00:03:38,455 You can simulate this in your browser by typing things like 51 00:03:38,455 --> 00:03:44,804 stackoverflow.com/search?q=http or 52 00:03:44,804 --> 00:03:49,785 google.com/maps?q=chicago. 53 00:03:49,785 --> 00:03:53,450 Those q parameters in the queries string 54 00:03:53,450 --> 00:03:58,470 are passed in get request to stack overflow and google maps respectively. 55 00:03:58,470 --> 00:04:02,020 The resulting pages show the results of your search. 56 00:04:02,020 --> 00:04:06,160 The key here is that in a get request, additional data related to 57 00:04:06,160 --> 00:04:10,080 your requested resource is passed as a query string in the URI.