Soup.MessageHeaders.get_ranges

### Method

# Soup MessageHeadersget_ranges

#### Declaration [src]

    gboolean
    soup_message_headers_get_ranges (
      SoupMessageHeaders* hdrs,
      goffset total_length,
      SoupRange** ranges,
      int* length
    )

#### Description [src]

Parses `hdrs`‘s Range header and returns an array of the requested byte ranges.

The returned array must be freed with `soup_message_headers_free_ranges()`.

If `total_length` is non-0, its value will be used to adjust the returned ranges to have explicit start and end values, and the returned ranges will be sorted and non-overlapping. If `total_length` is 0, then some ranges may have an end value of -1, as described under `SoupRange`, and some of the ranges may be redundant.

Beware that even if given a `total_length`, this function does not check that the ranges are satisfiable.

`SoupServer` has built-in handling for range requests. If your server handler returns a `SOUP_STATUS_OK` response containing the complete response body (rather than pausing the message and returning some of the response body later), and there is a Range header in the request, then libsoup will automatically convert the response to a `SOUP_STATUS_PARTIAL_CONTENT` response containing only the range(s) requested by the client.

The only time you need to process the Range header yourself is if either you need to stream the response body rather than returning it all at once, or you do not already have the complete response body available, and only want to generate the parts that were actually requested by the client.

#### Parameters

`total_length`

  Type: `goffset`

  The total_length of the response body.

`ranges`

  Type: An array of `SoupRange*`

  Return location for an array of `SoupRange`.

  The argument will be set by the function.
  The length of the array is specified in the `length` argument.
  The instance takes ownership of the data, and is responsible for freeing it.

`length`

  Type: `int*`

  The length of the returned array.

  The argument will be set by the function.

#### Return value

Type: `gboolean`

`TRUE` if `hdrs` contained a syntactically-valid “Range” header, `FALSE` otherwise (in which case `range` and `length` will not be set).