Middleware that handles HTTP range requests
Middleware that handles HTTP range requests
(buffer this response)
Start buffering until the body is read. Returns the number of bytes read.
Start buffering until the body is read. Returns the number of bytes read.
(anticipated-number-of-bytes-to-write-to-stream this
bytes
bytes-offset
bytes-length
num-bytes-read)
(content-range this total-body-length)
Value of the Content-Range header, given a total body length
Value of the Content-Range header, given a total body length
(end-byte this total-body-length)
Returns the end byte offset, given the total body length
Returns the end byte offset, given the total body length
(length this total-body-length)
Length of the range in bytes, given a total body length
Length of the range in bytes, given a total body length
(maybe-write-bytes-to-stream this
bytes
bytes-offset
bytes-length
num-bytes-read
output-stream)
(start-byte this total-body-length)
Returns the start byte offset, given the total body length
Returns the start byte offset, given the total body length
(to-closed-byte-range this total-body-length)
If the total body length is known, every range can be converted to a closed range form. This fn does that.
If the total body length is known, every range can be converted to a closed range form. This fn does that.
(valid? this)
(valid? this total-body-length)
Returns whether or not the range is valid. If the total body length is given, checks against that as well.
Returns whether or not the range is valid. If the total body length is given, checks against that as well.
(content-length this)
Precalculates the content length before the body is written
Precalculates the content length before the body is written
(range-header-response response request opts)
Fulfills the Range header request. See: wrap-range-header.
Fulfills the Range header request. See: wrap-range-header.
(validate-ranges ranges {:keys [max-num-ranges] :as opts})
(validate-ranges ranges opts total-body-length)
Checks that ranges are not overlapping relative to each other. NOTE: because the total body length may not be known, byte offsets cannot be absolutely checked. This means at most one of a suffix byte range or open-ended byte range can exist.
If the body length is known, the ranges are checked against the body length.
Checks that ranges are not overlapping relative to each other. NOTE: because the total body length may not be known, byte offsets cannot be absolutely checked. This means at most one of a suffix byte range or open-ended byte range can exist. If the body length is known, the ranges are checked against the body length.
(wrap-range-header handler)
(wrap-range-header handler opts)
Middleware that attempts to fulfill the Range header in the request, if any.
If the requested Range has valid byte offsets and no overlapping ranges, returns 206 with the requested bytes. Otherwise, returns the original response.
A single range is returned directly as bytes in the body. Multiple ranges are returned as a multipart/byteranges response as per RFC7233.
Accepts the following options:
:boundary-generator-fn - a function that returns a boundary string for multipart responses. Defaults to a randomly generated alphanumeric string :max-num-ranges - the maximum number of ranges to accept in the Range header. Default is 10. :max-buffer-size-per-range-bytes - maximum buffer size per range. Used when the Content-Length of the body is unknown. Defaults to 1MiB.
Middleware that attempts to fulfill the Range header in the request, if any. If the requested Range has valid byte offsets and no overlapping ranges, returns 206 with the requested bytes. Otherwise, returns the original response. A single range is returned directly as bytes in the body. Multiple ranges are returned as a multipart/byteranges response as per RFC7233. Accepts the following options: :boundary-generator-fn - a function that returns a boundary string for multipart responses. Defaults to a randomly generated alphanumeric string :max-num-ranges - the maximum number of ranges to accept in the Range header. Default is 10. :max-buffer-size-per-range-bytes - maximum buffer size per range. Used when the Content-Length of the body is unknown. Defaults to 1MiB.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close