Skip to content

HTTP status code 206 Partial Content

What is HTTP Response Status Code 206 Partial Content?

HTTP response status code 206 Partial Content indicates that the server is delivering only part of the requested resource due to a range header sent by the client.

When is HTTP Response Status Code 206 Partial Content Used?

The 206 status code is commonly used when a client requests only a portion of a file, such as streaming video or resuming a download.

Significance of HTTP Response Status Code 206 Partial Content in Web Development?

The 206 Partial Content status code allows for efficient data transfer, as clients can request specific parts of large files, reducing bandwidth usage and improving loading times for streaming content.

How to Implement HTTP Response Status Code 206 Partial Content?

To implement the 206 status code, the server should accept and process range headers from the client, delivering only the specified portion of the requested resource.

FAQs

  • When should I use a 206 status code? Use it when you need to deliver a part of a resource, such as during video streaming or file downloads.
  • Can a 206 response include the entire resource? No, it should only include the specific range requested by the client.
  • What is a range header? A range header specifies the portion of a resource that a client wants to retrieve from the server.

Example 1: Resuming a File Download

# Client sends a GET request with a range header to resume a download.
GET /files/report.pdf HTTP/1.1
Host: api.example.com
Range: bytes=500-999

# Server Response
HTTP/1.1 206 Partial Content
Date: Wed, 09 Oct 2024 10:50:00 GMT
Server: Apache/2.4.41 (Ubuntu)
Content-Range: bytes 500-999/2000
Content-Type: application/pdf

# Binary data for bytes 500-999 of the PDF file...

Example 2: Streaming a Video File

# Client requests a specific range of a video file for streaming.
GET /videos/sample.mp4 HTTP/1.1
Host: api.example.com
Range: bytes=10000-20000

# Server Response
HTTP/1.1 206 Partial Content
Date: Wed, 09 Oct 2024 10:52:00 GMT
Server: Nginx/1.18.0
Content-Range: bytes 10000-20000/500000
Content-Type: video/mp4

# Binary data for bytes 10000-20000 of the video file...

I am the founder of SEO Leaders and have been involved in the internet and web development in one way or another for over 20 years. Since founding SEO Leaders some 6 years ago I have been heavily involved in web develepment, Digital PR and technical SEO for a wide variety of projects. I hope to enlighten you on a wide range of topics related to my chosen profession!

Back To Top