HTTP GET Request


My first post here would be what is an HTTP Request.

When you fetch a page by typing the URL in the browser, The browser connects to the Host on port 80. Let us take an example, You type http://example.com/index.html and press enter

The browser first parses the URL and makes a Socket connection to example.com on port 80. The browser also parses the requested Resource or the page that is /index.html

The browser then writes the following to the socket

GET /index.html HTTP/1.1
Host: example.com

The request is completed when the last charecters are \r\n\r\n

The above request is a GET request, In HTTP any resource that you want to read/fetch we use the GET method. Notice the protocol, The first word is the method “GET” followed by a space and then path of the resource, which is then followed by the protocol and its version which is “HTTP/1.1”.

In the next line we mention the Host, which in our case is “example.com”, before HTTP/1.1, an IP could host only one Host/domain. From HTTP/1.1 the “Host” header became mandatory, so that multiple domains could be hosted on one IP, the server would grab the name of the Host from the header.

The request as I mentioned earlier, Is terminated by double returns.

You can try this yourself, without a browser, all you need is Telnet client .

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: