xrootd
|
#include <XrdHttpReadRangeHandler.hh>
Classes | |
struct | Configuration |
struct | Error |
struct | UserRange |
Public Types | |
typedef std::vector< UserRange > | UserRangeList |
Public Member Functions | |
XrdHttpReadRangeHandler (const Configuration &conf) | |
const Error & | getError () const |
bool | isFullFile () |
bool | isSingleRange () |
const UserRangeList & | ListResolvedRanges () |
const XrdHttpIOList & | NextReadList () |
void | NotifyError () |
int | NotifyReadResult (const ssize_t ret, const UserRange **const urp, bool &start, bool &allend) |
void | ParseContentRange (const char *const line) |
void | reset () |
int | SetFilesize (const off_t sz) |
Static Public Member Functions | |
static int | Configure (XrdSysError &Eroute, const char *const parms, Configuration &cfg) |
Static Public Attributes | |
static constexpr size_t | READV_MAXCHUNKS = 512 |
static constexpr size_t | READV_MAXCHUNKSIZE = 512*1024 |
static constexpr size_t | RREQ_MAXSIZE = 8*1024*1024 |
Private Member Functions | |
int | parseOneRange (char *const str) |
int | rangeFig (const char *const s, bool &set, off_t &start) |
void | resolveRanges () |
void | splitRanges () |
void | trimSplit () |
Private Attributes | |
Error | error_ |
UserRangeList | rawUserRanges_ |
bool | rangesResolved_ |
UserRangeList | resolvedUserRanges_ |
XrdHttpIOList | splitRange_ |
size_t | resolvedRangeIdx_ |
off_t | resolvedRangeOff_ |
size_t | splitRangeIdx_ |
off_t | splitRangeOff_ |
size_t | currSplitRangeIdx_ |
int | currSplitRangeOff_ |
off_t | filesize_ |
size_t | vectorReadMaxChunkSize_ |
size_t | vectorReadMaxChunks_ |
size_t | rRequestMaxBytes_ |
Class responsible for parsing the HTTP Content-Range header coming from the client, generating appropriate read ranges for read or readv and tracking the responses to the requests.
typedef std::vector<UserRange> XrdHttpReadRangeHandler::UserRangeList |
|
inline |
Constructor. Supplied with an Configuration object. The supplied object remains owned by the caller, but should remain valid throughout the lifetime of the ReadRangeHandler.
conf Configuration object.
References XrdHttpReadRangeHandler::Configuration::haveSizes, XrdHttpReadRangeHandler::Configuration::readv_ior_max, XrdHttpReadRangeHandler::Configuration::readv_iov_max, READV_MAXCHUNKS, READV_MAXCHUNKSIZE, XrdHttpReadRangeHandler::Configuration::reqs_max, reset(), RREQ_MAXSIZE, rRequestMaxBytes_, vectorReadMaxChunks_, and vectorReadMaxChunkSize_.
|
static |
Parses a configuration into a Configuration object.
Eroute Error reporting object
parms Configuration string.
cfg an output Configuration object
const Error & XrdHttpReadRangeHandler::getError | ( | ) | const |
bool XrdHttpReadRangeHandler::isFullFile | ( | ) |
Indicates no valid Range header was given and thus the implication is that whole file is required. A range or ranges may be given that cover the whole file but that situation is not detected.
bool XrdHttpReadRangeHandler::isSingleRange | ( | ) |
Incidcates whether there is a single range, either given by a Range header with single range or implied by having no Range header. Also returns true for an empty file, although there is no range of bytes.
const UserRangeList & XrdHttpReadRangeHandler::ListResolvedRanges | ( | ) |
Returns a reference of the list of ranges. These are resolved, meaning that if there was no Range header, or it was in the form -N or N-, the file size is used to compute the actual range of bytes that are needed. The list remains owned by the handler and may be invalidated on reset().
const XrdHttpIOList & XrdHttpReadRangeHandler::NextReadList | ( | ) |
Requests a XrdHttpIOList (vector of XrdOucIOVec2) that describes the next bytes that need to be fetched from a file. If there is more than one chunk it is size appropriately for a readv request, if there is one request it should be sent as a read request. Therefore the chunks do not necessarily correspond to the ranges the user requested. The caller issue the requests in the order provided and call NotifyReadResult with the ordered results.
void XrdHttpReadRangeHandler::NotifyError | ( | ) |
Force the handler to enter error state. Sets a generic error message if there was not already an error.
int XrdHttpReadRangeHandler::NotifyReadResult | ( | const ssize_t | ret, |
const UserRange **const | urp, | ||
bool & | start, | ||
bool & | allend | ||
) |
Notifies the handler about the arrival of bytes from a read or readv request. The handler tracks the progress of the arriving bytes against the bytes ranges the user requested.
ret | the number of bytes received |
urp | a pointer to a pointer of a UserRange object. If urp is not nullptr, the pointer to a UserRange is returned that describes the current range associated with the received bytes. The handler retains ownership of the returned object. reset() of the handler invalidates the UserRange object. |
start | is an output bool parameter that indicates whether the received bytes mark the start of a UserRange. |
allend | is an output bool parameter that indicates whether the received bytes mark the end of all the UserRanges |
void XrdHttpReadRangeHandler::ParseContentRange | ( | const char *const | line | ) |
Parses the Content-Range header value and sets the ranges within the object.
line | the line under the format "bytes=0-19, 25-30" In case the parsing fails any partial results are cleared. There is no error notification as the rest of the request processing should continue in any case. |
|
private |
|
private |
void XrdHttpReadRangeHandler::reset | ( | ) |
Resets the object state, ready for handling a new request.
Referenced by XrdHttpReadRangeHandler().
|
private |
int XrdHttpReadRangeHandler::SetFilesize | ( | const off_t | sz | ) |
Notifies of the current file size. This information is required for processing range requests that imply reading to the end or a certain position before the end of a file. It is also used to determine when read or readv need no longer be issued when reading the whole file. Can be called once or more, after reset() but before isSingleRange(), ListResolvedRanges() or NextReadList() methods.
sz | the size of the file |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
staticconstexpr |
These are defaults for: READV_MAXCHUNKS Max length of the XrdHttpIOList vector. READV_MAXCHUNKSIZE Max length of a XrdOucIOVec2 element. RREQ_MAXSIZE Max bytes to issue in a whole readv/read.
Referenced by XrdHttpReadRangeHandler().
|
staticconstexpr |
Referenced by XrdHttpReadRangeHandler().
|
private |
|
private |
|
private |
|
staticconstexpr |
Referenced by XrdHttpReadRangeHandler().
|
private |
Referenced by XrdHttpReadRangeHandler().
|
private |
|
private |
|
private |
|
private |
Referenced by XrdHttpReadRangeHandler().
|
private |
Referenced by XrdHttpReadRangeHandler().