xrootd
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Public Attributes | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
XrdHttpReq Class Reference

#include <XrdHttpReq.hh>

Inheritance diagram for XrdHttpReq:
Inheritance graph
[legend]
Collaboration diagram for XrdHttpReq:
Collaboration graph
[legend]

Public Types

enum  ReqType {
  rtUnset = -1 , rtUnknown = 0 , rtMalformed , rtGET ,
  rtHEAD , rtPUT , rtOPTIONS , rtPATCH ,
  rtDELETE , rtPROPFIND , rtMKCOL , rtMOVE ,
  rtPOST
}
 These are the HTTP/DAV requests that we support. More...
 

Public Member Functions

 XrdHttpReq (XrdHttpProtocol *protinstance, const XrdHttpReadRangeHandler::Configuration &rcfg)
 
virtual ~XrdHttpReq ()
 
virtual void reset ()
 
int parseLine (char *line, int len)
 Parse the header.
 
int parseFirstLine (char *line, int len)
 Parse the first line of the header.
 
int parseBody (char *body, long long len)
 Parse the body of a request, assuming that it's XML and that it's entirely in memory.
 
int ReqReadV (const XrdHttpIOList &cl)
 Prepare the buffers for sending a readv request.
 
std::string buildPartialHdr (long long bytestart, long long byteend, long long filesize, char *token)
 Build a partial header for a multipart response.
 
std::string buildPartialHdrEnd (char *token)
 Build the closing part for a multipart response.
 
void appendOpaque (XrdOucString &s, XrdSecEntity *secent, char *hash, time_t tnow)
 
void addCgi (const std::string &key, const std::string &value)
 
int ProcessHTTPReq ()
 
virtual bool Data (XrdXrootd::Bridge::Context &info, const struct iovec *iovP, int iovN, int iovL, bool final)
 
virtual bool Done (XrdXrootd::Bridge::Context &info)
 the result context
 
virtual bool Error (XrdXrootd::Bridge::Context &info, int ecode, const char *etext)
 
virtual int File (XrdXrootd::Bridge::Context &info, int dlen)
 
virtual bool Redir (XrdXrootd::Bridge::Context &info, int port, const char *hname)
 
- Public Member Functions inherited from XrdXrootd::Bridge::Result
virtual void Free (Bridge::Context &info, char *buffP, int buffL)
 
virtual bool Wait (Bridge::Context &info, int wtime, const char *wtext)
 
virtual Bridge::ResultWaitResp (Bridge::Context &info, int wtime, const char *wtext)
 
 Result ()
 Constructor & Destructor.
 
virtual ~Result ()
 

Public Attributes

std::vector< readahead_listralist
 
ReqType request
 The request we got.
 
std::string requestverb
 
std::map< std::string, std::string > allheaders
 
XrdOucString resource
 The resource specified by the request, stripped of opaque data.
 
XrdOucEnvopaque
 The opaque data, after parsing.
 
XrdOucString resourceplusopaque
 The resource specified by the request, including all the opaque data.
 
bool headerok
 Tells if we have finished reading the header.
 
XrdHttpReadRangeHandler readRangeHandler
 Tracking the next ranges of data to read during GET.
 
bool readClosing
 
bool keepalive
 
long long length
 
int depth
 
bool sendcontinue
 
std::string host
 The host field specified in the req.
 
std::string destination
 The destination field specified in the req.
 
std::string m_req_digest
 The requested digest type.
 
XrdHttpChecksumHandler::XrdHttpChecksumRawPtr m_req_cksum = nullptr
 The checksum that was ran for this request.
 
XrdOucString m_resource_with_digest
 
std::string m_digest_header
 The computed digest for the HTTP response header.
 
std::string hdr2cgistr
 Additional opaque info that may come from the hdr2cgi directive.
 
bool m_appended_hdr2cgistr
 
unsigned int rwOpDone
 To coordinate multipart responses across multiple calls.
 
unsigned int rwOpPartialDone
 
ClientRequest xrdreq
 The last issued xrd request, often pending.
 
XResponseType xrdresp
 The last response data we got.
 
XErrorCode xrderrcode
 
std::string etext
 
XrdOucString redirdest
 
const struct iovec * iovP
 The latest data chunks got from the xrd layer. These are valid only inside the callbacks!
 
int iovN
 array count
 
int iovL
 byte count
 
bool final
 true -> final result
 
long long filesize
 
long fileflags
 
long filemodtime
 
long filectime
 
char fhandle [4]
 
bool fopened
 
std::string stringresp
 If we want to give a string as a response, we compose it here.
 
int reqstate
 State machine to talk to the bridge.
 
long long writtenbytes
 In a long write, we track where we have arrived.
 
int mScitag
 

Private Member Functions

int parseHost (char *)
 
void parseScitag (const std::string &val)
 
void clientMarshallReadAheadList (int nitems)
 
void clientUnMarshallReadAheadList (int nitems)
 
void getfhandle ()
 
int PostProcessChecksum (std::string &digest_header)
 
int PostProcessHTTPReq (bool final=false)
 
void parseResource (char *url)
 
void mapXrdErrorToHttpStatus ()
 
void sanitizeResourcePfx ()
 
void getReadResponse (XrdHttpIOList &received)
 
int sendReadResponseSingleRange (const XrdHttpIOList &received)
 
int sendReadResponsesMultiRanges (const XrdHttpIOList &received)
 

Static Private Member Functions

static void extractChecksumFromList (const std::string &checksumList, std::vector< std::string > &extractedChecksum)
 
static void determineXRootDChecksumFromUserDigest (const std::string &userDigest, std::vector< std::string > &xrootdChecksums)
 

Private Attributes

int httpStatusCode
 
std::string httpStatusText
 
bool m_transfer_encoding_chunked
 
long long m_current_chunk_offset
 
long long m_current_chunk_size
 
bool m_trailer_headers {false}
 
bool m_status_trailer {false}
 
XrdHttpProtocolprot
 

Member Enumeration Documentation

◆ ReqType

These are the HTTP/DAV requests that we support.

Enumerator
rtUnset 
rtUnknown 
rtMalformed 
rtGET 
rtHEAD 
rtPUT 
rtOPTIONS 
rtPATCH 
rtDELETE 
rtPROPFIND 
rtMKCOL 
rtMOVE 
rtPOST 

Constructor & Destructor Documentation

◆ XrdHttpReq()

XrdHttpReq::XrdHttpReq ( XrdHttpProtocol protinstance,
const XrdHttpReadRangeHandler::Configuration rcfg 
)
inline

◆ ~XrdHttpReq()

virtual XrdHttpReq::~XrdHttpReq ( )
virtual

Member Function Documentation

◆ addCgi()

void XrdHttpReq::addCgi ( const std::string &  key,
const std::string &  value 
)

◆ appendOpaque()

void XrdHttpReq::appendOpaque ( XrdOucString s,
XrdSecEntity secent,
char *  hash,
time_t  tnow 
)

◆ buildPartialHdr()

std::string XrdHttpReq::buildPartialHdr ( long long  bytestart,
long long  byteend,
long long  filesize,
char *  token 
)

Build a partial header for a multipart response.

◆ buildPartialHdrEnd()

std::string XrdHttpReq::buildPartialHdrEnd ( char *  token)

Build the closing part for a multipart response.

◆ clientMarshallReadAheadList()

void XrdHttpReq::clientMarshallReadAheadList ( int  nitems)
private

◆ clientUnMarshallReadAheadList()

void XrdHttpReq::clientUnMarshallReadAheadList ( int  nitems)
private

◆ Data()

virtual bool XrdHttpReq::Data ( XrdXrootd::Bridge::Context info,
const struct iovec *  iovP,
int  iovN,
int  iovL,
bool  final 
)
virtual

Effect a client data response.

The Data() method is called when Run() resulted in a successful data response. The method should rewrite the data and send it to the client using the associated XrdLink object. As an example, 1) Result::Data(info, iovP, iovN, iovL) is called. 2) Inspect iovP, rewrite the data. 3) Send the response: info->linkP->Send(new_iovP, new_iovN, new_iovL); 4) Handle send errors and cleanup(e.g. deallocate storage). 5) Return, the exchange is now complete.

Parameters
infothe context associated with the result.
iovPa pointer to the iovec structure containing the xrootd data response about to be sent to the client. The request header is not included in the iovec structure. The elements of this structure must not be modified by the method.
iovNthe number of elements in the iovec structure array.
iovLtotal number of data bytes that would be sent to the client. This is simply the sum of all the lengths in the iovec.
finalTrue is this is the final result. Otherwise, this is a partial result (i.e. kXR_oksofar) and more data will result causing additional callbacks.
Returns
true continue normal processing. false terminate the bridge and close the link.
Parameters
infothe result context
iovPpointer to data array
iovNarray count
iovLbyte count
finaltrue -> final result

Implements XrdXrootd::Bridge::Result.

◆ determineXRootDChecksumFromUserDigest()

static void XrdHttpReq::determineXRootDChecksumFromUserDigest ( const std::string &  userDigest,
std::vector< std::string > &  xrootdChecksums 
)
staticprivate

Determine the XRootD-compliant checksum algorithm from the user digest string

Parameters
userDigestthe string containing the digest names. e.g: adler32, md5;q=0.4, md5
xrootdChecksumsthe vector that will contain the corresponding xrootd-compliant names These xrootd-compliant names are located in the static XrdOucString convert_digest_name(const std::string &rfc_name_multiple) function

◆ Done()

virtual bool XrdHttpReq::Done ( XrdXrootd::Bridge::Context info)
virtual

the result context

Effect a client acknowledgement.

The Done() method is called when Run() resulted in success and there is no associated data for the client (equivalent to a simple kXR_ok response).

Parameters
infothe context associated with the result.
Returns
true continue normal processing. false terminate the bridge and close the link.

Implements XrdXrootd::Bridge::Result.

◆ Error()

virtual bool XrdHttpReq::Error ( XrdXrootd::Bridge::Context info,
int  ecode,
const char *  etext 
)
virtual

Effect a client error response.

The Error() method is called when an error was encountered while processing the Run() request. The error should be reflected to the client.

Parameters
infothe context associated with the result.
ecodethe "kXR" error code describing the nature of the error. The code is in host byte format.
etexta null terminated string describing the error in human terms
Returns
true continue normal processing. false terminate the bridge and close the link.
Parameters
infothe result context
ecodethe "kXR" error code
etextassociated error message

Implements XrdXrootd::Bridge::Result.

◆ extractChecksumFromList()

static void XrdHttpReq::extractChecksumFromList ( const std::string &  checksumList,
std::vector< std::string > &  extractedChecksum 
)
staticprivate

Extract a comma separated list of checksums+metadata into a vector

Parameters
checksumListthe list like "0:sha1, 1:adler32, 2:md5"
extractedChecksumthe vector with the elements {0:sha,1:adler32,2:md5}

◆ File()

virtual int XrdHttpReq::File ( XrdXrootd::Bridge::Context info,
int  dlen 
)
virtual

Notify callback that a sendfile() request is pending.

The File() method is called when Run() resulted in a sendfile response (i.e. sendfile() would have been used to send data to the client). This allows the callback to reframe the sendfile() data using the Send() method in the passed context object (see class Context above).

Parameters
infothe context associated with the result.
dlentotal number of data bytes that would be sent to the client.
Returns
true continue normal processing. false terminate the bridge and close the link.
Parameters
infothe result context
dlenbyte count

Implements XrdXrootd::Bridge::Result.

◆ getfhandle()

void XrdHttpReq::getfhandle ( )
private

◆ getReadResponse()

void XrdHttpReq::getReadResponse ( XrdHttpIOList received)
private

◆ mapXrdErrorToHttpStatus()

void XrdHttpReq::mapXrdErrorToHttpStatus ( )
private

◆ parseBody()

int XrdHttpReq::parseBody ( char *  body,
long long  len 
)

Parse the body of a request, assuming that it's XML and that it's entirely in memory.

◆ parseFirstLine()

int XrdHttpReq::parseFirstLine ( char *  line,
int  len 
)

Parse the first line of the header.

◆ parseHost()

int XrdHttpReq::parseHost ( char *  )
private

◆ parseLine()

int XrdHttpReq::parseLine ( char *  line,
int  len 
)

Parse the header.

◆ parseResource()

void XrdHttpReq::parseResource ( char *  url)
private

◆ parseScitag()

void XrdHttpReq::parseScitag ( const std::string &  val)
private

◆ PostProcessChecksum()

int XrdHttpReq::PostProcessChecksum ( std::string &  digest_header)
private

◆ PostProcessHTTPReq()

int XrdHttpReq::PostProcessHTTPReq ( bool  final = false)
private

Cook and send the response after the bridge did something Return values: 0->everything OK, additionsl steps may be required 1->request processed completely -1->error

◆ ProcessHTTPReq()

int XrdHttpReq::ProcessHTTPReq ( )

Crunch an http request. Return values: 0->call Process again 1->request processed -1->error

◆ Redir()

virtual bool XrdHttpReq::Redir ( XrdXrootd::Bridge::Context info,
int  port,
const char *  hname 
)
virtual

Redirect the client to another host:port.

The Redir() method is called when the client must be redirected to another host.

Parameters
infothe context associated with the result.
portthe port number in host byte format.
hnamethe DNS name of the host or IP address is IPV4 or IPV6 format (i.e. "n.n.n.n" or "[ipv6_addr]").
Returns
true continue normal processing. false terminate the bridge and close the link.
Parameters
infothe result context
portthe port number
hnamethe destination host

Implements XrdXrootd::Bridge::Result.

◆ ReqReadV()

int XrdHttpReq::ReqReadV ( const XrdHttpIOList cl)

Prepare the buffers for sending a readv request.

◆ reset()

virtual void XrdHttpReq::reset ( )
virtual

◆ sanitizeResourcePfx()

void XrdHttpReq::sanitizeResourcePfx ( )
private

◆ sendReadResponseSingleRange()

int XrdHttpReq::sendReadResponseSingleRange ( const XrdHttpIOList received)
private

◆ sendReadResponsesMultiRanges()

int XrdHttpReq::sendReadResponsesMultiRanges ( const XrdHttpIOList received)
private

Member Data Documentation

◆ allheaders

std::map<std::string, std::string> XrdHttpReq::allheaders

◆ depth

int XrdHttpReq::depth

Referenced by XrdHttpReq().

◆ destination

std::string XrdHttpReq::destination

The destination field specified in the req.

◆ etext

std::string XrdHttpReq::etext

◆ fhandle

char XrdHttpReq::fhandle[4]

◆ filectime

long XrdHttpReq::filectime

◆ fileflags

long XrdHttpReq::fileflags

◆ filemodtime

long XrdHttpReq::filemodtime

◆ filesize

long long XrdHttpReq::filesize

◆ final

bool XrdHttpReq::final

true -> final result

◆ fopened

bool XrdHttpReq::fopened

Referenced by XrdHttpReq().

◆ hdr2cgistr

std::string XrdHttpReq::hdr2cgistr

Additional opaque info that may come from the hdr2cgi directive.

◆ headerok

bool XrdHttpReq::headerok

Tells if we have finished reading the header.

Referenced by XrdHttpReq().

◆ host

std::string XrdHttpReq::host

The host field specified in the req.

◆ httpStatusCode

int XrdHttpReq::httpStatusCode
private

◆ httpStatusText

std::string XrdHttpReq::httpStatusText
private

◆ iovL

int XrdHttpReq::iovL

byte count

◆ iovN

int XrdHttpReq::iovN

array count

◆ iovP

const struct iovec* XrdHttpReq::iovP

The latest data chunks got from the xrd layer. These are valid only inside the callbacks!

pointer to data array

◆ keepalive

bool XrdHttpReq::keepalive

◆ length

long long XrdHttpReq::length

Referenced by XrdHttpReq().

◆ m_appended_hdr2cgistr

bool XrdHttpReq::m_appended_hdr2cgistr

◆ m_current_chunk_offset

long long XrdHttpReq::m_current_chunk_offset
private

◆ m_current_chunk_size

long long XrdHttpReq::m_current_chunk_size
private

◆ m_digest_header

std::string XrdHttpReq::m_digest_header

The computed digest for the HTTP response header.

◆ m_req_cksum

XrdHttpChecksumHandler::XrdHttpChecksumRawPtr XrdHttpReq::m_req_cksum = nullptr

The checksum that was ran for this request.

◆ m_req_digest

std::string XrdHttpReq::m_req_digest

The requested digest type.

◆ m_resource_with_digest

XrdOucString XrdHttpReq::m_resource_with_digest

The checksum algorithm is specified as part of the opaque data in the URL. Hence, when a digest is generated to satisfy a request, we cache the tweaked URL in this data member.

◆ m_status_trailer

bool XrdHttpReq::m_status_trailer {false}
private

◆ m_trailer_headers

bool XrdHttpReq::m_trailer_headers {false}
private

◆ m_transfer_encoding_chunked

bool XrdHttpReq::m_transfer_encoding_chunked
private

◆ mScitag

int XrdHttpReq::mScitag

Referenced by XrdHttpReq().

◆ opaque

XrdOucEnv* XrdHttpReq::opaque

The opaque data, after parsing.

Referenced by XrdHttpReq().

◆ prot

XrdHttpProtocol* XrdHttpReq::prot
private

Referenced by XrdHttpReq().

◆ ralist

std::vector<readahead_list> XrdHttpReq::ralist

◆ readClosing

bool XrdHttpReq::readClosing

◆ readRangeHandler

XrdHttpReadRangeHandler XrdHttpReq::readRangeHandler

Tracking the next ranges of data to read during GET.

◆ redirdest

XrdOucString XrdHttpReq::redirdest

◆ reqstate

int XrdHttpReq::reqstate

State machine to talk to the bridge.

◆ request

ReqType XrdHttpReq::request

The request we got.

◆ requestverb

std::string XrdHttpReq::requestverb

◆ resource

XrdOucString XrdHttpReq::resource

The resource specified by the request, stripped of opaque data.

◆ resourceplusopaque

XrdOucString XrdHttpReq::resourceplusopaque

The resource specified by the request, including all the opaque data.

◆ rwOpDone

unsigned int XrdHttpReq::rwOpDone

To coordinate multipart responses across multiple calls.

◆ rwOpPartialDone

unsigned int XrdHttpReq::rwOpPartialDone

◆ sendcontinue

bool XrdHttpReq::sendcontinue

◆ stringresp

std::string XrdHttpReq::stringresp

If we want to give a string as a response, we compose it here.

◆ writtenbytes

long long XrdHttpReq::writtenbytes

In a long write, we track where we have arrived.

Referenced by XrdHttpReq().

◆ xrderrcode

XErrorCode XrdHttpReq::xrderrcode

◆ xrdreq

ClientRequest XrdHttpReq::xrdreq

The last issued xrd request, often pending.

◆ xrdresp

XResponseType XrdHttpReq::xrdresp

The last response data we got.


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