QHttpHeaderRangeSpec Struct
QHttpHeaderRangeSpec represents a single byte range as used in the HTTP Range and Content-Range headers, which RFC 9110 calls a range-spec. More...
| Header: | #include <QHttpHeaderRangeSpec> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS Network)target_link_libraries(mytarget PRIVATE Qt6::Network) |
| qmake: | QT += network |
| Since: | Qt 6.12 |
| Status: | Technology preview |
This struct is in technology preview and is subject to change.
QHttpHeaderRangeSpec Comparisons
| Category | Comparable Types |
|---|---|
| equality | QHttpHeaderRangeSpec |
Public Functions
| bool | isValid() const |
Public Variables
Related Non-Members
(since 6.12) size_t | qHash(QHttpHeaderRangeSpec key, size_t seed = 0) |
(since 6.12) QDebug | operator<<(QDebug debug, const QHttpHeaderRangeSpec &range) |
Detailed Description
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 isValid() to check whether a range spec is well-formed before passing it to QHttpHeaders::setRangeValues().
See also QHttpHeaderRangeSet, QHttpHeaders::rangeValues(), and QHttpHeaders::setRangeValues().
Member Function Documentation
[constexpr noexcept] bool QHttpHeaderRangeSpec::isValid() const
Returns true if the range spec is well-formed, false otherwise.
A range spec is considered invalid if:
- 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.
Member Variable Documentation
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.
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.
Related Non-Members
[noexcept, since 6.12] size_t qHash(QHttpHeaderRangeSpec key, size_t seed = 0)
Returns the hash value for key, using seed to seed the calculation.
This function was introduced in Qt 6.12.
[since 6.12] QDebug operator<<(QDebug debug, const QHttpHeaderRangeSpec &range)
Writes range to the debug stream.
This function was introduced in Qt 6.12.