Documentation ¶
Overview ¶
Package httphdr implements functionality for parsing and formatting standard HTTP headers.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FormatContentRange ¶
FormatContentRange parses a "Content-Range" header per RFC 7233, section 4.2. It only handles "Content-Range" headers where the units is "bytes". The "Content-Range" header is usually only specified in HTTP responses.
If start and length are non-positive, then it encodes just the completeLength, which must be a non-negative value.
Otherwise, it encodes the start and length as a byte-range, and optionally emits the complete length if it is non-negative. The length must be positive (as RFC 7233 uses inclusive end offsets).
func FormatRange ¶
FormatRange formats a "Range" header per RFC 7233, section 3. It only handles "Range" headers where the units is "bytes". The "Range" header is usually only specified in GET requests.
func ParseContentRange ¶
ParseContentRange parses a "Content-Range" header per RFC 7233, section 4.2. It only handles "Content-Range" headers where the units is "bytes". The "Content-Range" header is usually only specified in HTTP responses.
If only the completeLength is specified, then start and length are both zero.
Otherwise, the parses the start and length and the optional completeLength, which is -1 if unspecified. The start is non-negative and the length is positive.
Types ¶
type Range ¶
type Range struct { // Start is the starting offset. // It is zero if Length is negative; it must not be negative. Start int64 // Length is the length of the content. // It is zero if the length extends to the end of the content. // It is negative if the length is relative to the end (e.g., last 5 bytes). Length int64 }
Range is a range of bytes within some content.
func ParseRange ¶
ParseRange parses a "Range" header per RFC 7233, section 3. It only handles "Range" headers where the units is "bytes". The "Range" header is usually only specified in GET requests.