206 Partial Content는 클라이언트가 Range 헤더로 요청한 리소스의 일부(바이트 구간)만 서버가 전달했음을 나타냅니다. 응답의 Content-Range 헤더가 어떤 구간을 전체 크기 중 어디까지 보냈는지 알려 줍니다.
이 코드는 이어받기(끊긴 다운로드 재개)와 미디어 스트리밍의 핵심으로, 큰 파일을 통째로 다시 받지 않고 필요한 부분만 가져오게 해 줍니다.
GET /video.mp4 HTTP/1.1
Host: media.example.com
Range: bytes=1048576-2097151HTTP/1.1 206 Partial Content
Content-Range: bytes 1048576-2097151/5242880
Content-Length: 1048576
Content-Type: video/mp4
Accept-Ranges: bytes
(binary chunk)# request bytes 500-999 of a file
curl -H 'Range: bytes=500-999' https://media.example.com/video.mp4 -o part
# or resume a broken download
curl -C - -O https://media.example.com/video.mp4const res = await fetch('/video.mp4', {
headers: { Range: 'bytes=0-1023' }
});
console.log(res.status); // 206
console.log(res.headers.get('Content-Range'));