416

Range Not Satisfiable

개요

416 Range Not Satisfiable는 클라이언트가 Range 헤더로 요청한 바이트 구간이 리소스의 실제 크기를 벗어났다는 뜻입니다. 예를 들어 5MB 파일에서 100MB 지점의 바이트를 요구하면 발생합니다.

이 코드는 재개 가능한 다운로드나 미디어 스트리밍에서 클라이언트가 이미 파일 크기를 잘못 알고 있을 때 자주 나타납니다. 서버는 응답에 Content-Range: bytes */<총크기>를 담아 실제 크기를 알려줍니다.

언제 발생하나

요청 / 응답 예시

요청
GET /video.mp4 HTTP/1.1
Host: cdn.example.com
Range: bytes=99999999-100000000
응답
HTTP/1.1 416 Range Not Satisfiable
Content-Range: bytes */5242880
Content-Type: text/plain

Requested range not satisfiable

코드로 보기

const size = fs.statSync(file).size;
const m = /bytes=(\d+)-(\d*)/.exec(req.headers.range || '');
const start = m ? Number(m[1]) : 0;
if (start >= size) {
  res.writeHead(416, { 'Content-Range': `bytes */${size}` });
  return res.end();
}
# Ask for the first 1024 bytes; a valid range yields 206, an out-of-bounds one 416
curl -r 0-1023 https://cdn.example.com/video.mp4 -o chunk.bin

흔한 원인

해결 방법

실무 참고

관련 상태코드

관련 헤더

스펙 근거