![]() |
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 |
return the Error object More... | |
bool | isFullFile () |
indicates when there were no valid Range head ranges supplied More... | |
bool | isSingleRange () |
indicates a single range (implied whole file, or single range) or empty file More... | |
const UserRangeList & | ListResolvedRanges () |
return resolved (i.e. obsolute start and end) byte ranges desired More... | |
const XrdHttpIOList & | NextReadList () |
return XrdHttpIOList for sending to read or readv More... | |
void | NotifyError () |
Force handler to enter error state. More... | |
int | NotifyReadResult (const ssize_t ret, const UserRange **const urp, bool &start, bool &allend) |
Advance internal counters concerning received bytes. More... | |
void | ParseContentRange (const char *const line) |
parse the line after a "Range: " http request header More... | |
void | reset () |
resets this handler More... | |
int | SetFilesize (const off_t sz) |
sets the filesize, used during resolving and issuing range requests More... | |
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 |
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.
Definition at line 36 of file XrdHttpReadRangeHandler.hh.
typedef std::vector<UserRange> XrdHttpReadRangeHandler::UserRangeList |
Definition at line 103 of file XrdHttpReadRangeHandler.hh.
|
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.
Definition at line 113 of file XrdHttpReadRangeHandler.hh.
References XrdHttpReadRangeHandler::Configuration::haveSizes, XrdHttpReadRangeHandler::Configuration::readv_ior_max, XrdHttpReadRangeHandler::Configuration::readv_iov_max, READV_MAXCHUNKS, READV_MAXCHUNKSIZE, XrdHttpReadRangeHandler::Configuration::reqs_max, reset(), and RREQ_MAXSIZE.
|
static |
Parses a configuration into a Configuration object.
Definition at line 42 of file XrdHttpReadRangeHandler.cc.
References XrdOuca2x::a2i(), XrdHttpReadRangeHandler::Configuration::haveSizes, XrdHttpReadRangeHandler::Configuration::readv_ior_max, XrdHttpReadRangeHandler::Configuration::readv_iov_max, XrdHttpReadRangeHandler::Configuration::reqs_max, RREQ_MAXSIZE, XrdOucTUtils::splitString(), and XrdOucUtils::trim().
const XrdHttpReadRangeHandler::Error & XrdHttpReadRangeHandler::getError | ( | ) | const |
bool XrdHttpReadRangeHandler::isFullFile | ( | ) |
indicates when there were no valid Range head ranges supplied
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.
Definition at line 94 of file XrdHttpReadRangeHandler.cc.
bool XrdHttpReadRangeHandler::isSingleRange | ( | ) |
indicates a single range (implied whole file, or single range) or empty file
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.
Definition at line 102 of file XrdHttpReadRangeHandler.cc.
Referenced by XrdHttpReq::ProcessHTTPReq().
const XrdHttpReadRangeHandler::UserRangeList & XrdHttpReadRangeHandler::ListResolvedRanges | ( | ) |
return resolved (i.e. obsolute start and end) byte ranges desired
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().
Definition at line 113 of file XrdHttpReadRangeHandler.cc.
const XrdHttpIOList & XrdHttpReadRangeHandler::NextReadList | ( | ) |
return XrdHttpIOList for sending to read or readv
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.
Definition at line 129 of file XrdHttpReadRangeHandler.cc.
References XrdHttpReadRangeHandler::Error::set().
Referenced by XrdHttpReq::ProcessHTTPReq().
void XrdHttpReadRangeHandler::NotifyError | ( | ) |
Force handler to enter error state.
Force the handler to enter error state. Sets a generic error message if there was not already an error.
Definition at line 173 of file XrdHttpReadRangeHandler.cc.
References XrdHttpReadRangeHandler::Error::set().
Referenced by XrdHttpReq::File().
int XrdHttpReadRangeHandler::NotifyReadResult | ( | const ssize_t | ret, |
const UserRange **const | urp, | ||
bool & | start, | ||
bool & | allend | ||
) |
Advance internal counters concerning received bytes.
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 |
Definition at line 184 of file XrdHttpReadRangeHandler.cc.
References XrdHttpReadRangeHandler::Error::set().
Referenced by XrdHttpReq::File().
void XrdHttpReadRangeHandler::ParseContentRange | ( | const char *const | line | ) |
parse the line after a "Range: " http request header
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. |
Definition at line 272 of file XrdHttpReadRangeHandler.cc.
Referenced by XrdHttpReq::parseLine().
void XrdHttpReadRangeHandler::reset | ( | ) |
resets this handler
Resets the object state, ready for handling a new request.
Definition at line 318 of file XrdHttpReadRangeHandler.cc.
References XrdHttpReadRangeHandler::Error::reset().
Referenced by XrdHttpReadRangeHandler(), and XrdHttpReq::reset().
int XrdHttpReadRangeHandler::SetFilesize | ( | const off_t | sz | ) |
sets the filesize, used during resolving and issuing range requests
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 |
Definition at line 340 of file XrdHttpReadRangeHandler.cc.
References XrdHttpReadRangeHandler::Error::set().
|
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.
Definition at line 45 of file XrdHttpReadRangeHandler.hh.
Referenced by XrdHttpReadRangeHandler().
|
staticconstexpr |
Definition at line 46 of file XrdHttpReadRangeHandler.hh.
Referenced by XrdHttpReadRangeHandler().
|
staticconstexpr |
Definition at line 47 of file XrdHttpReadRangeHandler.hh.
Referenced by XrdHttpReadRangeHandler(), and Configure().