Skip to content

HTTP

  • Stands for Hyper Text Transfer Protocol
  • Web Server is HTTP server.
  • Web Browser is HTTP client.
  • HTTP protocol generally takes place over TCP connection.
  • It listens on port 80.
  • In HTTP, clients sends a HTTP request and server sends backs HTTP response.
  • HTTP is stateless.

Client Server Model

  • A server is a process that offers some service.
  • A client is a process that is requesting the service.
  • Server waits for clients to get the request.

HTTP Request and Response Message

a. HTTP Request Message

  1. Request Line
  2. Headers
  3. A blank Line
  4. Body

a. HTTP Response Message

  1. Status Line
  2. Headers
  3. A blank Line
  4. Body

HTTP Methods

  1. Get - Requests data from the server
  2. HEAD - Requests information about a data but not the data itself.
  3. POST - Sends some data to the server
  4. PUT - Updates some data to the server
  5. TRACE - Echoes the incoming request
  6. CONNECT - Reserved
  7. OPTION - Inquires about available options

HTTP Status Code

  1. Informational

  2. 100 - Continue

  3. 101 - Switching

  4. Success

  5. 200 - OK : The request is successful

  6. 201 - Created : A new URL is created.
  7. 202 - Accepted : The request is accepted but it - is not immediately acted upon.
  8. 204 - No content : There is no content in the body.

  9. Redirection

  10. 301 - Moved Permanently : The requested URL is no longer used by the server.

  11. 302 - Moved Temporarily : The requested URL has moved temporarily.
  12. 304 - Not modified : The document has not been modified.

  13. Client Error

  14. 400 - Bad Request : There is a error in the request.

  15. 401 - Unauthorized : The request lacks proper authorization.
  16. 403 - Forbidden : Service is denied.
  17. 404 - Not Found : The document is not found.
  18. 405 - Method not allowed : This method is not supported in the URL.
  19. 406 - Not acceptable : The format reqested is not acceptable.

  20. Server Error

  21. 500 - Internal Server Error : There is an error at the server side.

  22. 501 - Not implemented : The action requeted cannot be performed.
  23. 503 - Service unavaible : The service is temporarily unavailable, but may be requested in the future.

HTTP Request Header

  1. Cache-control : Specifies information about caching.
  2. Connection : Shows whether the connection should be closed or not.
  3. Date : Shows the current date.
  4. MIME-version : Shows the MIME version used.
  5. Upgrade : Specifies the preferred communication protocol.
  6. Accept
  7. Accept-charset
  8. Accept-language
  9. Authorization
  10. User-agent, etc

HTTP Response Headers

  1. Accept-range
  2. Age
  3. Public
  4. Retry-after
  5. Server

HTTP Entity Headers

  1. Allow
  2. Content-encoding
  3. Content-language
  4. Content-length
  5. Content-range
  6. Content-type
  7. Expires
  8. Last-modified
  9. Location

HTTP1 vs HTTP2

  • HTTP2 is much faster and more reliable than HTTP1.
  • HTTP1 loads a single request for every TCP connection, while HTTP2 avoids network delay by using multiplexing.

Features of HTTP2

  • Binary Protocol - While HTTP/1.x was a text based protocol, HTTP/2 is a binary protocol resulting in less error during data transfer process.
  • Multiplexed Streams - All HTTP/2 connections are multiplexed streams meaning multiple files can be transferred in a single stream of binary data.
  • Compressed Header - HTTP/2 compresses header data in responses resulting in faster transfer of data.
  • Server Push - This capability allows the server to send linked resources to the client automatically, greatly reducing the number of requests to the server.
  • Stream Prioritization - HTTP/2 can prioritize data streams based on their type resulting in better bandwidth allocation where necessary.