Tuesday, 23 May 2017

What is HTTP Headers & Methods ?

WHAT IS HTTP HEADERS & METHODS ?

INTRODUCTION:

HTTP stands for “Hypertext Transfer Protocol“. The entire World Wide Web uses this protocol. It was established in the early 1990’s. Almost everything you see in your browser is transmitted to your computer over HTTP.  HTTP/1.1 is the version of HTTP in common use.
HTTP is based on the client-server architecture model and a stateless request/response protocol that operates by exchanging messages across a reliable TCP/IP connection.
E.g. HTTP Request Message
GET /hello.htm HTTP/1.1User-Agent: Mozilla/4.0 (compatible; MSIE5.01; Windows NT)Host: www.tutorialspoint.comAccept-Language: en-usAccept-Encoding: gzip, deflateConnection: Keep-Alive
E.g. HTTP Response Message
POST /cgi-bin/process.cgi HTTP/1.1User-Agent: Mozilla/4.0 (compatible; MSIE5.01; Windows NT)Host: www.tutorialspoint.comContent-Type: application/x-www-form-urlencodedContent-Length: lengthAccept-Language: en-usAccept-Encoding: gzip, deflateConnection: Keep-Alive licenseID=string&content=string&/paramsXML=string

HTTP METHODS:

HTTP defines a set of request methods to indicate the desired action to be performed for a given resource.
  1. GET – The GET method is used to retrieve information from the given server using a given URL. Requests using GET should only retrieve data and should have no other effects on the data.
  2. HEAD – Same as GET, but transfer the status line and header section only.
  3. POST – A POST request is used to send data to the server, for example, customer information, file upload, etc. Using HTML forms.
  4. PUT – Replaces all the current representation of the target resource with the uploaded content.
  5. DELETE – Removes all current representation of the target resource given by a URL.
  6. CONNECT – Establishes a tunnel to the server identified by a given URL.
  7. OPTIONS – Describes the communication option for the target resources.
  8. TRACE – Performs a message loop-back test along the path to the target resource.

HTTP RESPONSE STATUS CODES


HTTP response status codes indicate whether a specific HTTP request has been successfully completed. Responses are grouped into five classes: informational responses, successful responses, redirects, client errors, and server’s errors.

  1. 1XX – Informational
It means the request has been received and the process is continuing.
  1. 2XX – Success
It means the action was successfully received, understood and accepted.
  1. 3XX – Redirection
It means further action must be taken in order to complete the request.
  1. 4XX – Client Error
It means the request contains incorrect syntax or cannot be fulfilled.
  1. 5XX – Server Error
It means the server failed to fulfill an apparently valid request.
The Internet Engineering Task Force has released a DRAFT on July 8, 2013, which describes an advanced version of HTTP, which in the coming near future will become an RFC for HTTP version 2 Protocol. This future version of HTTP will be having a good number of advanced features, which the current version lacks.
There were some main shortcomings in HTTP version 1 protocol and HTTP version 1.1, which are addressed by HTTP version 2. Some of these shortcomings are mentioned below.
  • HTTP version 1 allowed processing of only one request at a time. Due to this, clients will have to make multiple HTTP connections to the server, to reduce page load time.
  • Headers in multiple requests were repetitive and were very descriptive, which results in generation of larger packets(in other words previous versions were not using network resources in an optimized manner)
HTTP version 2 is also an application layer protocol, similar to previous versions. Some of the new advancements in HTTP version 2 are based on a protocol developed by Google called as speedy.
Recommended: HTTP Request and Response