Content-Length Header

Table of Content

The Content-Length entity-header field provides the size, in bytes, of the entity-body, sent to the recipient. It is used in HTTP, SFTP and SIP protocols to specify the size of the message body. Primarily, it facilitates the recipient in knowing when it has successfully finished receiving all of the message data.

Syntax

The Content-Length header is expressed in US-ASCII decimal digits. This is how the general syntax looks:

Content-Length: {length}

Where {length} specifies the size of the body in bytes.

Directives

The Content-Length header doesn’t define any particular directives. It simply carries the length of the body in bytes, which may be a number from 0 and upwards.

Examples

Here's how the header might look in context:

GET /index.html HTTP/1.1  
Host: www.example.com  
Content-Length: 348  

This header signifies that the size of the entity-body that will be sent to the recipient should be 348 bytes.

Browser Compatibility

Browser Compatibility
Chrome Supported
Firefox Supported
Safari Supported
Opera Supported
Edge Supported

All major browsers fully support the Content-Length header.

How to modify Content-Length header

ModHeader is a browser extension that lets you modify request headers. Here's how you can use it to adjust Content-Length:

  1. Install and open ModHeader.
  2. An "Add" button will appear next to the Headers input box. Click on it.
  3. In the first box that appears, type "Content-Length".
  4. In the box next to it, type the desired content length.
  5. The new Content-Length will now be included in the header of all outgoing HTTP requests.

Modifying Content-Length may be useful for testing server behavior under different content sizes. You might, for example, want to see how your server handles exceptionally long or short messages.