Skip to content
Related Articles
Get the best out of our app
GeeksforGeeks App
Open App
geeksforgeeks
Browser
Continue

Related Articles

HTTP headers | Range

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

HTTP headers are used to pass additional information with HTTP request or response. HTTP range is an HTTP request header that is used to get part of a document from the server. If the server returns the part of the document, it uses the 206 (Partial Content) status code. If ranges are invalid status code used is 416 (Range Not Satisfiable) and the server uses status code 200 (OK) in case it ignores the range request.

Syntax:

  • To get whole document starting from a particular range
    Range: <unit>=<range-start>-
  • To request multiple parts
    Range: <unit>=<range-start>-<range-end>, <range-start>-<range-end>
  • To request specific end part of the document
    Range: <unit>=-<suffix-length>

Directives: There are four directives accepted by HTTP Range header, mentioned above and described below:

  • unit: It specifies the unit in which range is given. Generally bytes are used.
  • range-start: It is the integer specifying the starting of the document part.
  • range-end: It is the integer specifying the ending of the document part. It is an optional directive.
  • suffix-length: It is an integer indicating the end part of the document to be returned.

Examples:

  • To get first 100 bytes of the file
    Range: bytes=0-99
  • To get last 100 bytes of the file
    Range: bytes=-100
  • To request multiple ranges
    Range: bytes=0-99, 700-799

To check this Range in action go to Inspect Element -> Network check the request header for Range.

Supported Browsers: The browsers supported by HTTP header Range are listed below:

  • Google Chrome
  • Internet Explorer
  • Firefox
  • Safari
  • Opera
My Personal Notes arrow_drop_up
Last Updated : 31 Oct, 2019
Like Article
Save Article
Similar Reads
Related Tutorials