QHttpHeaderRange Class
QHttpHeaderRange represents a single byte range as used in the HTTP Range and Content-Range headers. More...
| Header: | #include <QHttpHeaderRange> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS Network)target_link_libraries(mytarget PRIVATE Qt6::Network) |
| qmake: | QT += network |
| Since: | Qt 6.12 |
QHttpHeaderRange Comparisons
| Category | Comparable Types |
|---|---|
| equality | QHttpHeaderRange |
Public Functions
| QHttpHeaderRange() | |
| QHttpHeaderRange(std::optional<qint64> start, std::optional<qint64> end) | |
| std::optional<qint64> | end() const |
| bool | isValid() const |
| void | setEnd(std::optional<qint64> end) |
| void | setStart(std::optional<qint64> start) |
| std::optional<qint64> | start() const |
Related Non-Members
(since 6.12) size_t | qHash(QHttpHeaderRange key, size_t seed = 0) |
(since 6.12) QDebug | operator<<(QDebug debug, const QHttpHeaderRange &range) |
Detailed Description
A range 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 is well-formed before passing it to QHttpHeaders::setRangeValues().
See also QHttpHeaders::rangeValues() and QHttpHeaders::setRangeValues().
Member Function Documentation
[constexpr noexcept default] QHttpHeaderRange::QHttpHeaderRange()
Constructs a default-initialized range. Both start() and end() will be std::nullopt. The resulting range is not valid according to isValid().
[constexpr noexcept] QHttpHeaderRange::QHttpHeaderRange(std::optional<qint64> start, std::optional<qint64> end)
Constructs a range with start and end byte offsets. Either or both may be std::nullopt to represent an open-ended range; see isValid() for the constraints.
[constexpr noexcept] std::optional<qint64> QHttpHeaderRange::end() const
Returns 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 setEnd() and start().
[constexpr noexcept] bool QHttpHeaderRange::isValid() const
Returns true if the range is well-formed, false otherwise.
A range 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.
[constexpr noexcept] void QHttpHeaderRange::setEnd(std::optional<qint64> end)
Sets the end byte offset to end. Pass std::nullopt to clear the end.
See also end() and setStart().
[constexpr noexcept] void QHttpHeaderRange::setStart(std::optional<qint64> start)
Sets the start byte offset to start. Pass std::nullopt to clear the start.
See also start() and setEnd().
[constexpr noexcept] std::optional<qint64> QHttpHeaderRange::start() const
Returns 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.
Related Non-Members
[noexcept, since 6.12] size_t qHash(QHttpHeaderRange 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 QHttpHeaderRange &range)
Writes range to the debug stream.
This function was introduced in Qt 6.12.