xrootd
Loading...
Searching...
No Matches
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

◆ UserRangeList

Constructor & Destructor Documentation

◆ XrdHttpReadRangeHandler()

XrdHttpReadRangeHandler::XrdHttpReadRangeHandler ( const Configuration conf)
inline

Member Function Documentation

◆ Configure()

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

Parses a configuration into a Configuration object.

Parameters

Eroute Error reporting object

Parameters

parms Configuration string.

Parameters

cfg an output Configuration object

Returns
0 for success, otherwise failure.

◆ getError()

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.

◆ isFullFile()

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.

◆ isSingleRange()

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.

◆ ListResolvedRanges()

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.

◆ NextReadList()

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.

◆ NotifyError()

void XrdHttpReadRangeHandler::NotifyError ( )

Force the handler to enter error state. Sets a generic error message if there was not already an error.

◆ NotifyReadResult()

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.

◆ ParseContentRange()

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.

◆ parseOneRange()

int XrdHttpReadRangeHandler::parseOneRange ( char *const  str)
private

◆ rangeFig()

int XrdHttpReadRangeHandler::rangeFig ( const char *const  s,
bool &  set,
off_t &  start 
)
private

◆ reset()

void XrdHttpReadRangeHandler::reset ( )

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

Referenced by XrdHttpReadRangeHandler().

◆ resolveRanges()

void XrdHttpReadRangeHandler::resolveRanges ( )
private

◆ SetFilesize()

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.

◆ splitRanges()

void XrdHttpReadRangeHandler::splitRanges ( )
private

◆ trimSplit()

void XrdHttpReadRangeHandler::trimSplit ( )
private

Member Data Documentation

◆ currSplitRangeIdx_

size_t XrdHttpReadRangeHandler::currSplitRangeIdx_
private

◆ currSplitRangeOff_

int XrdHttpReadRangeHandler::currSplitRangeOff_
private

◆ error_

Error XrdHttpReadRangeHandler::error_
private

◆ filesize_

off_t XrdHttpReadRangeHandler::filesize_
private

◆ rangesResolved_

bool XrdHttpReadRangeHandler::rangesResolved_
private

◆ rawUserRanges_

UserRangeList XrdHttpReadRangeHandler::rawUserRanges_
private

◆ READV_MAXCHUNKS

constexpr size_t XrdHttpReadRangeHandler::READV_MAXCHUNKS = 512
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().

◆ READV_MAXCHUNKSIZE

constexpr size_t XrdHttpReadRangeHandler::READV_MAXCHUNKSIZE = 512*1024
staticconstexpr

Referenced by XrdHttpReadRangeHandler().

◆ resolvedRangeIdx_

size_t XrdHttpReadRangeHandler::resolvedRangeIdx_
private

◆ resolvedRangeOff_

off_t XrdHttpReadRangeHandler::resolvedRangeOff_
private

◆ resolvedUserRanges_

UserRangeList XrdHttpReadRangeHandler::resolvedUserRanges_
private

◆ RREQ_MAXSIZE

constexpr size_t XrdHttpReadRangeHandler::RREQ_MAXSIZE = 8*1024*1024
staticconstexpr

Referenced by XrdHttpReadRangeHandler().

◆ rRequestMaxBytes_

size_t XrdHttpReadRangeHandler::rRequestMaxBytes_
private

Referenced by XrdHttpReadRangeHandler().

◆ splitRange_

XrdHttpIOList XrdHttpReadRangeHandler::splitRange_
private

◆ splitRangeIdx_

size_t XrdHttpReadRangeHandler::splitRangeIdx_
private

◆ splitRangeOff_

off_t XrdHttpReadRangeHandler::splitRangeOff_
private

◆ vectorReadMaxChunks_

size_t XrdHttpReadRangeHandler::vectorReadMaxChunks_
private

Referenced by XrdHttpReadRangeHandler().

◆ vectorReadMaxChunkSize_

size_t XrdHttpReadRangeHandler::vectorReadMaxChunkSize_
private

Referenced by XrdHttpReadRangeHandler().


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