[How Tomcat Works] Chapter 1. HTTP Request, HTTP Response

Published by

on

As web server usually uses HTTP to communicate with the client(e.g. web browser), it is commonly called as HTTP server.

Hypertext Transfer Protocol (HTTP)

  • HTTP uses TCP connection which is reliable
  • HTTP transaction always starts when client creates connection first and sends requests
    • Server doesn’t create connection by itself
  • Server and client can destroy the connection before the transaction is finished
  • The request and response are all represented with text. That’s why it’s named as hypertext protocol.

HTTP Request

Figure 1. HTTP Request
  • HTTP Request is composed of 3 elements
    1. Method – URI (Uniform Resource Identifier) – Protocol/Version
      • HTTP request supports methods like GET, POST, HEAD, OPTIONS, PUT, DELETE, TRACE. GET and POST are the most commonly used methods.
      • URI specifies the resource. URI is usually a relative path from the top directory of the server. It always starts with “/”
    2. Request headers
      • Request headers include information about client.
        • For example, the language configuration of the browser
    3. Entity body
      • An empty line between the headers and body distinguishes those two parts.

HTTP Response

Figure 2. HTTP Response
  • HTTP Request is composed of 3 elements
    1. Protocol – Status Code – Description
    2. Response headers
    3. Entity body

Leave a comment