411 Length Required는 서버가 요청 본문의 크기를 미리 알아야 하는데 Content-Length 헤더가 없어서 처리를 거부한다는 뜻입니다. 서버가 chunked transfer encoding을 지원하지 않거나, 정책상 본문 길이를 명시하도록 요구할 때 발생합니다.
대부분의 HTTP 클라이언트 라이브러리는 본문을 보낼 때 Content-Length를 자동으로 붙이므로, 이 오류는 주로 저수준 소켓 코드나 스트리밍 업로드에서 나타납니다.
POST /upload HTTP/1.1
Host: api.example.com
Content-Type: application/octet-stream
<binary body with no Content-Length>HTTP/1.1 411 Length Required
Content-Type: text/plain
Content-Length: 33
Content-Length header is required.# Let curl compute and send Content-Length from a file
curl -X POST --data-binary @payload.bin \
-H 'Content-Type: application/octet-stream' \
https://api.example.com/upload# Reject chunked requests where a length is mandatory
if ($http_content_length = "") {
return 411;
}