Skip to main content

Learn How Hyper Text Transfer Protocol Works




Introduction to HTTP :

Well, you daily surf Internet using your favorite Web Browser (Client) to access Web-Sites, Mails, and Social Sites etc.. But how all these stuffs works and communicate with each others ? Every Web-Site has an unique name called Domain Name also referred as (Uniform Resource Locator) URL, And every URL starts with four letter (string) (http://) HTTP (Hyper Text Transfer Protocol).


                                  http://www.demosite.com/members/register.php

where; 
             "http:" is the Protocol
             "www.demosite.com" is the World Wide Web Domain
             "members" is the Directory
             "register.php" is the Path Name of the website

Well Protocol means a set of rule and functions. Sometimes you might see (https://) (S) stands for secure : It means the communication is secure, Sometimes ports are also included in URL (http://localhost:8080/).

The HTTP (Hyper Text Transfer Protocol) is an application protocol used to request web server for web pages, applications, scripts, medias and Dynamic pages. HTTP is responsible for responding client’s request and to delivers web pages to client’s browser. HTTP is simple text based protocol. HTTP is only the protocol for communication between client and server. 


Suppose you want to access Google site on your browser. You type URL in your browser and hit enter, at that moment your browser generates HTTP request including Domain Name, Path, Method, Directory and Requested File and send it to server, The Request goes through the Internet to the server and server responds you back with HTML, JavaScript, Images and CSS files that your browser can understand and finally it display’s on your screen.

The Most Important : HTTP is stateless protocol. It doesn’t manage State.

History and About :

  1. HTTP is Text based User-Interface Protocol
  2. HTTP works on Request / Response Mechanism
  3. Sir. Tim Berners Lee invented HTTP 0.9 in 1989
  4. Latest version of HTTP is 1.1 (Upcoming HTTP 2.0)
  5. HTTP was never created for online Banking, Cloud Computing etc.
  6. HTTP Request Methods (GET, POST, HEAD, PUT, Trace etc..)
  7. HTTP delivers Hypermedia contents to client’s browser
  8. Default port for HTTP is Port 80 and 443 for HTTPS.
  9. HTTPS is either Protected by SSL or TLS for secure communication
  10. HTTP is responsible for responding client’s request and deliver Web Pages
 
Web Architecture and Flow :





Above image gave you slight knowledge of Web Architecture and Flow. As you saw every communication was carried out by HTTP. The Client requested for a resource on server using URL. Your Browser generated request and sent it to server, And finally server responded with requested resource containing (HTML, CSS and JavaScript) file. Every request/response pass through a Firewall or WAF (Web Application Firewall) between client side and server side. 

The Client Side : The Client side is also called : User Side. Client’s browser saves scripted file (HTML, JS & CSS) inside DOM (Document Object Module) received by Server as requested data and displays on your Screen. Unfortunately Client side validation can be bypassed easily, by tampering HTTP parameter. 

The Server Side : The Server side is everything that is responsible for managing Database, Web Applications Flow, Application Plugins (PHP, ASP, Python, C etc..) and Communication between Client and Server. A Web server has different mechanisms for Authorization, Authentication and Protocols for communication like : FTP, SMTP, SSL, HTTP, etc…

Web Servers : Apache, IIS etc.. (Take a good look once again on previous page diagram)

How HTTP Works :


So, Here comes the main question. Let’s clear this out friends. Your favorite browser is a HTTP Communication tool, Well imagine you’re using Google Chrome to access a site (http://localhost.com) when you type URL and hit enter, it generates request and send it to localhost.com server, Now server reads HTTP request and response requested content. Check out below images in which Request/Response mechanism are shown respectively.



As you saw in above image diagram - flow of HTTP, Now it’s time to explore HTTP request headers. Method, Host, User-Agent, Connection etc.. Are all headers containing information about client and request.



The Method header always comes first, GET and POST are common methods used to request web server. Just after request method, It shows HTTP version. The current version of HTTP is 1.1. The Second line contain Host or Domain. It is also called as the “Request receiver”. Third Line : Connection should be alive. Fourth line describes what language the client’s browser can read and accept. User-Agent is client’s browser name. And the last two lines : Define what language and encoding can be accepted. Except first two headers, all are default by browser, and after response it add Cookies.

There is nothing hard about learning how HTTP works, all you need to put little interested. So now we’ll explore and learn Response header. After receiving request from client, Server always responds with various Response Code & other headers. The response header contains most important part called : Body. The Body part contains HTML, JavaScript, CSS and Other medias that your browser can read and display.


HTTP Response Message :

In Response Message : There are two part. The Above part is HTTP Response Headers and Below part is called The Body Part and the blank line Separating both content is called CRLF.



HTTP Response Header : The First line represents HTTP version and Response code! (We’ll learn a lot about Response code in next page.) After that it shows Date and Server Information. The fourth line counts content-length. Keep-Alive and Connection are default by server. ContentType represents what type of content – Server delivered to Client. Like text/html and charset = UTF-8.

HTTP Response Code :


HTTP Response Code represents the reaction and response of requested URL/Directory. Mostly you’ll get 200 OK (It means your request has been completed successfully and you can receive requested file in your Browser) I guess you all are familiar with one of the most common and popular HTTP Response code : 404 Not Found. Assume you type www.facebook.com you’ll get 200 OK Response code, but if you try to access someone else private pictures or locked data you’ll get client error 404 Not Found.



HTTP Methods :

Well, you know the two most common HTTP Methods GET and POST. But do you know that there are some more Methods. Let’s get hands on it.



Now I can wish you all learned almost all basics about HTTP. Hope you loved it.

Comments

Post a Comment

Hi, thanks for your feedback. We received your message and we will contact you soon. Cheers!