Tuesday, June 30, 2015

Introduction to HTTP

The Hypertext Transfer Protocol (HTTP) is a request–response protocol in the client–server computing model that has been in use by the World-Wide Web. HTTP is the foundation of data communication for the World Wide Web.  Whenever you surf the web, your browser will be sending HTTP request messages for HTML pages, images, scripts and styles sheets. Web servers handle these requests by returning response messages that contain the requested resource.

A web browser is an example of a user agent (UA). Other types of user agent include the indexing software used by search providers (web crawlers), voice browsers, mobile apps, and other software that accesses, consumes, or displays web content.

HTTP is an application layer protocol designed within the framework of the Internet Protocol Suite. Transmission Control Protocol (TCP) is commonly used. However HTTP can be adapted to use unreliable protocols such as the User Datagram Protocol (UDP), for example in HTTPU and Simple Service Discovery Protocol (SSDP).

Coming to the versions of HTTP, the first documented version was HTTP/0.9 & officially introduced and recognized HTTP/1.0 but soon HTTP/1.1 was released and widely used even at the time of writing this post. After more than a decade HTTP/2 was developed supported by most of the modern browsers. HTTP/2 was developed from the earlier experimental SPDY protocol, originally developed by Google.

Below mentioned is the screenshot of the worlds 1st website & it's still online!!! you can experience it yourself by clicking here 




HTTP Request Message

The HTTP request message has a simple text based structure. For example, here is the the request message sent by Google Chrome for this web page:


GET / HTTP/1.1
Host: www.spiceupyourknowledge.net
Connection: keep-alive
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Accept-Encoding: gzip, deflate, sdch
Accept-Language: en-US,en;q=0.8

The first line of the message, known as the request line, contains:
  • The HTTP method. (Will look into HTTP Methods in a different post)
  • The relative URL of the resource or a full URL if you are using an HTTP proxy
  • The version of HTTP that is being used.
The rest of the message consists of a set of name/value pairs, known as headers (We will lookinto HTTP Headers in a different post). HTTP clients use header values to control how the request is processed by the server. For example, the Accept-Encoding header indicates that the browser can handle content compressed using the gzip or deflate algorithms or sdch


HTTP Response Message

The web server's response message has a similar structure, but is followed by the contents of the HTML page:

HTTP/1.1 200 OK
Date: Wed, 07 Sep 2016 18:41:37 GMT
Cache-Control: private, max-age=0
Expires: Wed, 07 Sep 2016 18:41:37 GMT
Content-Type: text/html; charset=UTF-8
ETag: W/"d5085d33a59aaa77c8568b8fe01bf409cb322f346ac650d8f6eb3cf1076ed5dd"
Last-Modified: Wed, 07 Sep 2016 15:37:01 GMT
Content-Length: 12893


The first line, or status line, returns a status code from the server that indicates whether the request was successful (Will look into Status codes in a different post). The value 200 is returned if the request was processed correctly and content is being returned to the client.


The remaining lines contain header values that describe the data and the way in which it is being returned to the client. For example, Content-Type has the value text/html because the page is in HTML format.

Since this is just a introduction to HTTP I will stop here. We can look into the details of HTTP in the upcoming post, so stay tuned to Spice Up Your Knowledge...



Leave your comment below


No comments:

Post a Comment