GET request

After reviewing the URL structure and the headers, let's try a GET request on a real server.

In order to do so, I will use the Terminal and telnet command to send a raw GET request to the server. This is our attempt at simulating a browser by typing in the Telnet connection.

Perform the following steps:

  1. Let's switch to our VM and open up the Terminal and type the following:
telnet www.httpbin.org 80
80 is the port we want Telnet to connect to. httpbin.org is a website that provides an HTTP request and response service that is useful to test tools.

Hit Enter.

  1. Once we connect, we will see the following message:

This means the connection is established.

  1. Next, let's type GET /ip HTTP/1.0 and hit Enter twice. This is us telling the server that we are using GET to request the resource called /ip. Then, we specify the HTTP/1.0 protocol followed by pressing Enter twice. As a result, we get our first response from the server:

Notice that we haven't used any headers at all in the request, but we received many headers from the server, plus the content of the resource IP.

In this case, the content is the IP address of the machine making the request.

Now, let's take another example, but this time requesting a URL that has a parameter.

Open up the Terminal and type:

telnet www.httpbin.org 80
GET /redirect-to?url=http://www.bing.com HTTP/1.0

Again, we used GET, but this time we are requesting the resource redirect to with the parameter URL in the query string with the value http://www.bing.com:

In this case, the server basically redirects the browser to the URL provided, using the location header and returning a 302 redirection code. In this case, nothing happens, as Telnet doesn't interpret that header. Remember, this is a rule connection.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.118.45.162