xrootd
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Classes | Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes | List of all members
XrdHttpReadRangeHandler Class Reference

#include <XrdHttpReadRangeHandler.hh>

Collaboration diagram for XrdHttpReadRangeHandler:
Collaboration graph
[legend]

Classes

struct  Configuration
 
struct  Error
 
struct  UserRange
 

Public Types

typedef std::vector< UserRangeUserRangeList
 

Public Member Functions

 XrdHttpReadRangeHandler (const Configuration &conf)
 
const ErrorgetError () const
 
bool isFullFile ()
 
bool isSingleRange ()
 
const UserRangeListListResolvedRanges ()
 
const XrdHttpIOListNextReadList ()
 
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_
 

Detailed Description

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.

Member Typedef Documentation

Constructor & Destructor Documentation

XrdHttpReadRangeHandler::XrdHttpReadRangeHandler ( const Configuration conf)
inline

Member Function Documentation

static int XrdHttpReadRangeHandler::Configure ( XrdSysError Eroute,
const char *const  parms,
Configuration cfg 
)
static

Parses a configuration into a Configuration object.

Parameters
@ErouteError reporting object
@parmsConfiguration string.
@cfgan output Configuration object
Returns
0 for success, otherwise failure.
const Error& XrdHttpReadRangeHandler::getError ( ) const

getter for the Error object. The object can be inspected with its operator bool() method to indicate an error has happened. Error code and message are available in other members of Error.

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.

Returns
true if there is a single range.
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().

Returns
List of ranges in a UserRangeList object. The returned list may be empty, i.e. for an empty file or if there is an error. Use getError() to see if there is an error.
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.

Returns
a reference to a XrdHttpIOList. The object remains owned by the handler. It may be invalided by a new call to NextReadList() or reset(). The returned list may be empty, which implies no more reads are needed One can use getError() to see if there is an error.
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.

Parameters
retthe number of bytes received
urpa 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.
startis an output bool parameter that indicates whether the received bytes mark the start of a UserRange.
allendis an output bool parameter that indicates whether the received bytes mark the end of all the UserRanges
Returns
0 upon success, -1 if an error happened. One needs to call the getError() method to return the error.
void XrdHttpReadRangeHandler::ParseContentRange ( const char *const  line)

Parses the Content-Range header value and sets the ranges within the object.

Parameters
linethe 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.
int XrdHttpReadRangeHandler::parseOneRange ( char *const  str)
private
int XrdHttpReadRangeHandler::rangeFig ( const char *const  s,
bool &  set,
off_t &  start 
)
private
void XrdHttpReadRangeHandler::reset ( )

Resets the object state, ready for handling a new request.

Referenced by XrdHttpReadRangeHandler().

void XrdHttpReadRangeHandler::resolveRanges ( )
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.

Parameters
szthe size of the file
Returns
0 upon success, -1 if an error happened. One needs to call the getError() method to return the error.
void XrdHttpReadRangeHandler::splitRanges ( )
private
void XrdHttpReadRangeHandler::trimSplit ( )
private

Member Data Documentation

size_t XrdHttpReadRangeHandler::currSplitRangeIdx_
private
int XrdHttpReadRangeHandler::currSplitRangeOff_
private
Error XrdHttpReadRangeHandler::error_
private
off_t XrdHttpReadRangeHandler::filesize_
private
bool XrdHttpReadRangeHandler::rangesResolved_
private
UserRangeList XrdHttpReadRangeHandler::rawUserRanges_
private
constexpr size_t XrdHttpReadRangeHandler::READV_MAXCHUNKS = 512
static

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().

constexpr size_t XrdHttpReadRangeHandler::READV_MAXCHUNKSIZE = 512*1024
static

Referenced by XrdHttpReadRangeHandler().

size_t XrdHttpReadRangeHandler::resolvedRangeIdx_
private
off_t XrdHttpReadRangeHandler::resolvedRangeOff_
private
UserRangeList XrdHttpReadRangeHandler::resolvedUserRanges_
private
constexpr size_t XrdHttpReadRangeHandler::RREQ_MAXSIZE = 8*1024*1024
static

Referenced by XrdHttpReadRangeHandler().

size_t XrdHttpReadRangeHandler::rRequestMaxBytes_
private

Referenced by XrdHttpReadRangeHandler().

XrdHttpIOList XrdHttpReadRangeHandler::splitRange_
private
size_t XrdHttpReadRangeHandler::splitRangeIdx_
private
off_t XrdHttpReadRangeHandler::splitRangeOff_
private
size_t XrdHttpReadRangeHandler::vectorReadMaxChunks_
private

Referenced by XrdHttpReadRangeHandler().

size_t XrdHttpReadRangeHandler::vectorReadMaxChunkSize_
private

Referenced by XrdHttpReadRangeHandler().


The documentation for this class was generated from the following file: