Security Terms/Network Security

HTTP Response Headers

ayosecu 2025. 1. 20. 19:12

HTTP Response Headers

HTTP Response Headers are key elements sent by the server to the client after receiving an HTTP request. These headers provide crucial information about the status of the request, the content being returned, and how the client should handle it. They help the client understand the nature of the server’s response, whether it was successful, and how to display or process the returned data.

Key Components of an HTTP Response Header

  1. HTTP Version

    • The response header includes the HTTP version that the server is using to communicate. This is important because different HTTP versions (e.g., HTTP/1.1 or HTTP/2) support different features and optimizations.
    • Example:
      HTTP/1.1 200 OK
  2. Status Codes

    • The status code in the response header indicates the result of the client’s request. It tells the client whether the request was successful, if there was an error, or if further action is required.
      Categories of Status Codes:
    • 1xx: Informational Response
      • These codes indicate that the request was received, but the server is still processing it. Commonly used during long operations or during protocol switching.
      • Example: 100 Continue
    • 2xx: Successful
      • These codes indicate that the request was successfully received, understood, and processed.
      • 200 OK: The request was successful, and the server is returning the requested resource.
      • 201 Created: The request has been fulfilled, and a new resource has been created.
    • 3xx: Redirection
      • These codes inform the client that further action is needed to complete the request, usually involving following a different URL.
      • 301 Moved Permanently: The requested resource has been moved to a new URL permanently.
      • 302 Found: The requested resource is temporarily at a different URL.
    • 4xx: Client Error
      • These codes indicate an error in the client’s request, such as bad syntax or requesting a resource that does not exist.
      • 400 Bad Request: The server could not understand the request due to invalid syntax.
      • 404 Not Found: The requested resource could not be found on the server.
    • 5xx: Server Error
      • These codes indicate that the server encountered an error while trying to fulfill the request.
      • 500 Internal Server Error: The server encountered a general error and could not complete the request.
      • 503 Service Unavailable: The server is temporarily unable to handle the request (e.g., due to overload or maintenance).
  3. Type of Data in the Response

    • The Content-Type header specifies the type of data being returned by the server. It tells the client how to interpret or render the response.
    • Example:
      Content-Type: text/html; charset=UTF-8
    • This means that the server is returning HTML content, and it should be displayed as a webpage.
  4. Type of Encoding

    • The Content-Encoding header specifies the type of compression used on the response body. It allows the server to compress the data (e.g., using gzip or deflate) to reduce transfer time, and the client can decompress it for display.
    • Example:
      Content-Encoding: gzip
    • This means that the content is compressed using gzip, and the client needs to decompress it to read the data.
  5. Language

    • The Content-Language header indicates the language of the response content. This helps the client display the correct language for the user.
    • Example:
      Content-Language: en-US
    • This means the content is in U.S. English.
  6. Charset

    • The charset specifies the character encoding used in the response. This is crucial for ensuring that the text in the response is properly displayed. The most common character set is UTF-8.
    • Example:
      Content-Type: text/html; charset=UTF-8
    • This indicates that the response is HTML, and the text should be interpreted using the UTF-8 character encoding.

Example of an HTTP Response Header

HTTP/1.1 200 OK
Content-Type: text/html; charset=UTF-8
Content-Encoding: gzip
Content-Language: en-US
Content-Length: 348

In this example:

  • HTTP Version: The server is using HTTP/1.1.
  • Status Code: The status is 200 OK, meaning the request was successful.
  • Content-Type: The server is returning HTML content, and it should be displayed using the UTF-8 character set.
  • Content-Encoding: The content is compressed using gzip.
  • Content-Language: The content is written in U.S. English.

Summary

  • HTTP Version: Specifies the version of the protocol.
  • Status Codes: Indicate the outcome of the request (1xx for informational, 2xx for success, 3xx for redirection, 4xx for client errors, and 5xx for server errors).
  • Content-Type: Specifies the format of the response data (e.g., text/html).
  • Content-Encoding: Indicates the type of compression applied to the response (e.g., gzip).
  • Content-Language: Specifies the language of the content.
  • Charset: Specifies the character encoding (e.g., UTF-8) used in the response content.

These headers are critical for proper communication between clients and servers, ensuring that the client knows how to interpret and process the server’s response.

'Security Terms > Network Security' 카테고리의 다른 글

Broadcast Domain vs Collision Domain  (0) 2025.01.20
UDP (User Datagram Protocol) Header  (0) 2025.01.20
HTTP Headers  (0) 2025.01.20
Service Ports  (0) 2025.01.20
RPC (Remote Procedure Call)  (0) 2025.01.20