411 Length Required

HTTP response status code 411 Length Required is a client error that is returned by the server to indicate that the request cannot be completed because the Content-Length HTTP header field is absent.

Usage

When the 411 Length Required error message is received, it means that the request must be resubmitted with the Content-Length HTTP header included. HTTP requests generally use this header to specify the length of the message body, although it is not always required. For example, when the Transfer-Encoding HTTP header field is included and set to chunked, the Content-Length HTTP header field is not required.

If the client is sending a stream of data and this status is returned, it will have to send the data in size-specified blocks, instead.

Note

Search engines like Google will not index a URL with 411 Length Required response status, and consequently, URLs that have been indexed in the past but are now returning this HTTP status code will be removed from the search results.

Example

In the example, the client attempts to send a file but the server denies the HTTP request with 411 Length Required because it wants to know how much data shall be included in the message body before saving it locally.

Request

PUT /docs HTTP/1.1
Host: www.example.re
Content-Type: applications/pdf

<PDF file included as message body>

Response

HTTP/1.1 411 Length Required

Code references

.NET

HttpStatusCode.LengthRequired

Rust

http::StatusCode::LENGTH_REQUIRED

Rails

:length_required

Go

http.StatusLengthRequired

Symfony

Response::HTTP_LENGTH_REQUIRED

Python3.5+

http.HTTPStatus.LENGTH_REQUIRED

Java

java.net.HttpURLConnection.HTTP_LENGTH_REQUIRED

Apache HttpComponents Core

org.apache.hc.core5.http.HttpStatus.SC_LENGTH_REQUIRED

Angular

@angular/common/http/HttpStatusCode.LengthRequired

Takeaway

The 411 Length Required status code is a client error presented to inform the client that the Content-Length HTTP Header field is mandatory, yet absent. The client can resubmit the request with a valid message body length.

See also

Last updated: August 2, 2023