Aarunya AppsAarunya Apps
206
Partial Content
Success

HTTP 206 Partial Content — Video Streaming & Resumable Downloads

The server is delivering only a portion of the resource due to a Range request from the client. Used for video streaming, resumable downloads, and large file transfers where the client requests specific byte ranges.

When to Return 206

Sent automatically by most HTTP servers when a client includes a Range: bytes=0-1023 header. Implement manually for streaming APIs that support range requests.

HTTP Response Example

HTTP/1.1 206 Partial Content
Content-Range: bytes 0-1023/10240
Content-Length: 1024
Content-Type: video/mp4

[binary data]

Code Examples

Express.js
app.get('/video/:id', (req, res) => {
  const { range } = req.headers
  const videoPath = `./videos/${req.params.id}.mp4`
  const stat = fs.statSync(videoPath)
  const [start, end] = range?.replace('bytes=', '').split('-').map(Number) ?? [0, stat.size - 1]
  const chunkSize = end - start + 1
  const file = fs.createReadStream(videoPath, { start, end })
  res.writeHead(206, {
    'Content-Range': `bytes ${start}-${end}/${stat.size}`,
    'Accept-Ranges': 'bytes',
    'Content-Length': chunkSize,
    'Content-Type': 'video/mp4',
  })
  file.pipe(res)
})
Next.js App Router
// next.config.js — static files in /public are served with
// Accept-Ranges by Next.js automatically. For custom routes:
export async function GET(request: Request) {
  const range = request.headers.get('range')
  // Parse range and return partial content
  return new Response(chunk, {
    status: 206,
    headers: { 'Content-Range': 'bytes 0-1023/10240' },
  })
}

Related Status Codes

All HTTP status codes

Browse the complete HTTP status code reference.

All Status Codes

Frequently Asked Questions

What does HTTP 206 Partial Content mean?

The server is delivering only a portion of the resource due to a Range request from the client. Used for video streaming, resumable downloads, and large file transfers where the client requests specific byte ranges.

When should an API return 206?

Sent automatically by most HTTP servers when a client includes a Range: bytes=0-1023 header. Implement manually for streaming APIs that support range requests.