Open In App

HTTP headers | Range

Last Updated : 31 Oct, 2019
Improve
Improve
Like Article
Like
Save
Share
Report

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

Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads