QHttpEngine
1.0.0
Simple and secure HTTP server for Qt applications
|
HTTP range representation. More...
#include <qhttpengine/range.h>
Public Member Functions | |
Range () | |
Create a new range. More... | |
Range (const QString &range, qint64 dataSize=-1) | |
Construct a range from the provided string. More... | |
Range (qint64 from, qint64 to, qint64 dataSize=-1) | |
Construct a range from the provided offsets. More... | |
Range (const Range &other, qint64 dataSize) | |
Construct a range from the another range's offsets. More... | |
~Range () | |
Destroy the range. | |
QString | contentRange () const |
Retrieve representation suitable for Content-Range header. More... | |
qint64 | dataSize () const |
Retrieve dataSize of range. More... | |
qint64 | from () const |
Retrieve starting position of range. More... | |
bool | isValid () const |
Checks if range is valid. More... | |
qint64 | length () const |
Retrieve length of range. More... | |
Range & | operator= (const Range &other) |
Assignment operator. | |
qint64 | to () const |
Retrieve ending position of range. More... | |
This class provides a representation of HTTP range, described in RFC 7233 and used when partial content is requested by the client. When an object is created, optional dataSize can be specified, so that relative ranges can be represented as absolute.
QHttpEngine::Range::Range | ( | ) |
An empty Range is considered invalid.
QHttpEngine::Range::Range | ( | const QString & | range, |
qint64 | dataSize = -1 |
||
) |
Parses string representation range and constructs new Range. For raw header "Range: bytes=0-100" only "0-100" should be passed to constructor. dataSize may be supplied so that relative ranges could be represented as absolute values.
QHttpEngine::Range::Range | ( | qint64 | from, |
qint64 | to, | ||
qint64 | dataSize = -1 |
||
) |
Initialises a new Range with from and to values. dataSize may be supplied so that relative ranges could be represented as absolute values.
QHttpEngine::Range::Range | ( | const Range & | other, |
qint64 | dataSize | ||
) |
QString QHttpEngine::Range::contentRange | ( | ) | const |
qint64 QHttpEngine::Range::dataSize | ( | ) | const |
If dataSize is not set, this method returns -1.
qint64 QHttpEngine::Range::from | ( | ) | const |
If range is set as 'last N bytes' and dataSize is not set, returns -N.
bool QHttpEngine::Range::isValid | ( | ) | const |
Range is considered invalid if it is out of bounds, that is when this inequality is false - (from <= to < dataSize).
When QHttpRange(const QString&) fails to parse range string, resulting range is also considered invalid.
qint64 QHttpEngine::Range::length | ( | ) | const |
If ending position is not set, and dataSize is not set, and range is not set as 'last N bytes', returns -1. If range is invalid, returns -1.
qint64 QHttpEngine::Range::to | ( | ) | const |
If range is set as 'last N bytes' and dataSize is not set, returns -1. If ending position is not set, and dataSize is not set, returns -1.