Basic Introduction to Learn about HTTP Protocol

At first what is Protocol? Protocol means a way of communication between two or more parties. To connect two parties like client and server at first we need to establish a connection between them and after that we need to start communication in such a way so that anyone can understand each other. To establish a connection we need a special protocol named Transmission Control Protocol/Internet Protocol (TCP/IP). Which has become the industry-standard method of interconnecting hosts, networks, and the Internet. Now think that connection between client and server has been established. Now we need to set a way of communication like messages, so that they can understand both. This message format standard is HTTP which defines how client will send a request to the server and how the server will response. HTTP stands for “Hypertext Transfer Protocol”. In case of Web Browser and Web Server, The Web Browser is HTTP Client and the Web Server is HTTP Server.

More precisely the definition of HTTP protocol is a protocol designed to allow the transfer of Hypertext Markup Language (HTML) documents.

An HTTP transaction is divided into four steps:
1. The browser opens a connection by using TCP/IP.

2. The browser sends a request to the server –> The request is a message and the message format follows HTTP Protocol.
3. The server sends a response to the browser –> The response also a message and the message format follows HTTP Protocol.

4. The connection is closed.

So what we understand? We understand on the Internet, HTTP communication generally takes place over TCP connections. The default port is 80 but other ports can be used..

HTTP Protocol is Connection less:

The protocol is called connection less because An HTTP client opens a connection and sends a request message to the HTTP server, After that the server then returns a response message containing the resource which was requested. After delivering the response, the server closes the connection unlike other protocol likes FTP, which makes HTTP Protocol is a connection less protocol.

HTTP protocol is State less:

When the server responded of client request, the connection between client and server is closed means forgotten. There is no “Tracking System” between client and server. The HTTP server takes every request as a new request means never maintain any connection information between transactions. But there are some ways to maintain states between client and server which i have already described in my previous article: “Passing data/parameters/values from one aspx page to another aspx page“.

HTTP Message Example:

GET /path/file.html HTTP/1.0
User-Agent: HTTPTool/1.0
[blank line here]


HTTP/4.0 200 OK
Content-Type: text/html
Content-Length: 2000

<h1>HELLO WORLD</h1>
(more file contents)

To know more about Content-Type CLICK HERE.

HTTP Methods:

The most commonly used methods are GET and POST. To know more about Get and POST method click “Difference between HTTP GET and POST methods“.

Other Common Methods are:

HEAD: A HEAD request is just like a GET request, except it asks the server to return the response headers only, and not the actual resource (i.e. no message body). This is useful to check characteristics of a resource without actually downloading it which saves bandwidth. Mostly wide use of this method is crawler.

PUT: Mostly used for uploading files.

Common HTTP Response Status Code:
Successful (2xx):
200: OK
201: Created
202: Accepted
203: Non-Authoritative Information
204: No Content -205 Reset Content
206: Partial Content

Redirection (3xx):
300: Multiple Choices
301: Moved Permanently
302: Moved Temporarily
303: See Other
304: Not Modified
305: Use Proxy

Client error (4xx):
400: Bad Request
401: Unauthorized
402: Payment Required
403: Forbidden
404: Not Found
405: Method Not Allowed
406: Not Acceptable
407: Proxy Authentication Required
408: Request Timeout
409: Conflict
410: Gone
411: Length Required
412: Precondition Failed
413: Request Entity Too Large
414: Request-URI Too Long
415: Unsupported Media Type

Server error (5xx):
500: Internal Server Error
502: Bad Gateway
503: Service Unavailable
504: Gateway Timeout
505: HTTP Version Not Supported

Posted in .Net, C# Interview Question

Leave a Reply

Your email address will not be published. Required fields are marked *