Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
QHttpHeaderRangeSpec Class Reference

QHttpHeaderRangeSpec represents a single byte range as used in the HTTP {Range} and {Content-Range} headers, which RFC 9110 calls a {range-spec}. More...

#include <qhttpheaders.h>

Collaboration diagram for QHttpHeaderRangeSpec:

Public Member Functions

constexpr bool isValid () const noexcept
 \variable std::optional<qint64> QHttpHeaderRangeSpec::start

Public Attributes

std::optional< qint64 > start
std::optional< qint64 > end

Friends

Q_NETWORK_EXPORT QDebug operator<< (QDebug debug, const QHttpHeaderRangeSpec &range)
constexpr bool comparesEqual (const QHttpHeaderRangeSpec &lhs, const QHttpHeaderRangeSpec &rhs) noexcept
size_t qHash (QHttpHeaderRangeSpec range, size_t seed=0) noexcept

Detailed Description

QHttpHeaderRangeSpec represents a single byte range as used in the HTTP {Range} and {Content-Range} headers, which RFC 9110 calls a {range-spec}.

Since
6.12 \inmodule QtNetwork \preliminary \compares equality

A range spec has an optional start and an optional end, both expressed as byte offsets. A missing start or end is represented as {std::nullopt}.

Use \l isValid() to check whether a range spec is well-formed before passing it to \l QHttpHeaders::setRangeValues().

See also
QHttpHeaderRangeSet
QHttpHeaders::rangeValues(), QHttpHeaders::setRangeValues()

Definition at line 27 of file qhttpheaders.h.

Member Function Documentation

◆ isValid()

bool QHttpHeaderRangeSpec::isValid ( ) const
inlineconstexprnoexcept

\variable std::optional<qint64> QHttpHeaderRangeSpec::start

Contains the start byte offset of the range, or {std::nullopt} if no start was set. A range without a start but with an end (e.g., {bytes=-500}) represents the last N bytes of the resource.

See also
end

\variable std::optional<qint64> QHttpHeaderRangeSpec::end

Contains the end byte offset of the range, or {std::nullopt} if no end was set. A range with a start but without an end (e.g., {bytes=500-}) requests all bytes from the given offset to the end of the resource.

See also
start

Returns true if the range spec is well-formed, false otherwise.

A range spec is considered invalid if: \list

  • Both start and end are {std::nullopt}.
  • The start value is negative.
  • The end value is negative.
  • Both start and end are set, and start is greater than end. \endlist

Definition at line 32 of file qhttpheaders.h.

◆ comparesEqual

bool comparesEqual ( const QHttpHeaderRangeSpec & lhs,
const QHttpHeaderRangeSpec & rhs )
friend

Definition at line 50 of file qhttpheaders.h.

◆ operator<<

Q_NETWORK_EXPORT QDebug operator<< ( QDebug debug,
const QHttpHeaderRangeSpec & range )
friend
Since
6.12

Writes range to the debug stream.

Definition at line 2271 of file qhttpheaders.cpp.

◆ qHash

size_t qHash ( QHttpHeaderRangeSpec range,
size_t seed = 0 )
friend

Definition at line 57 of file qhttpheaders.h.

Member Data Documentation

◆ end

std::optional<qint64> QHttpHeaderRangeSpec::end

Definition at line 30 of file qhttpheaders.h.

◆ start

std::optional<qint64> QHttpHeaderRangeSpec::start

Definition at line 29 of file qhttpheaders.h.


The documentation for this class was generated from the following files: