DELAPARRA
Index
Color
NL
Category: HTTP headers

Content-Length

Explained by Updated

What is Content-Length?

Content-Length: Size of the response body in bytes. Lets the client know how much to read. Content-Length states the size of a request or response body in bytes. The receiver uses it to know when the body ends and, for downloads, to show progress. You rarely set it yourself, because web servers and frameworks calculate it. When a response is streamed and the size is not known in advance, the server uses chunked transfer encoding instead and leaves Content-Length out.

Definition source Coders Lingo, CC BY 4.0

Frequently asked questions about Content-Length

What should you keep in mind with Content-Length?

It becomes relevant when something is wrong. A mismatch between the header and the real body size can cause truncated downloads or requests that hang. Servers also use it to reject uploads that are too large before reading them. If file uploads fail at a certain size, check upload limits in PHP, the web server and any proxy in front of it; all of them look at this value.

What does an example of Content-Length look like?

Content-Length: 4823

At a glance

CategoryHTTP headers
Explained by
Updated

More HTTP headers terms

All terms starting with C

Skills

Download all skills (zip)

Manuals

Related services

Need any help?

Stuck on one of these in your own project? Tell me what you are working on and I will tell you how I would approach it.