xrootd
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Types | Public Member Functions | Public Attributes | 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)
 
virtual ~XrdHttpReq ()
 
virtual void reset ()
 
int parseLine (char *line, int len)
 Parse the header. More...
 
int parseFirstLine (char *line, int len)
 Parse the first line of the header. More...
 
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. More...
 
int ReqReadV ()
 Prepare the buffers for sending a readv request. More...
 
std::string buildPartialHdr (long long bytestart, long long byteend, long long filesize, char *token)
 Build a partial header for a multipart response. More...
 
std::string buildPartialHdrEnd (char *token)
 Build the closing part for a multipart response. More...
 
void appendOpaque (XrdOucString &s, XrdSecEntity *secent, char *hash, time_t tnow)
 
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 More...
 
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. More...
 
virtual ~Result ()
 

Public Attributes

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

Private Member Functions

int parseContentRange (char *)
 
int parseHost (char *)
 
int parseRWOp (char *)
 
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 ()
 

Private Attributes

int httpStatusCode
 
std::string httpStatusText
 
bool m_transfer_encoding_chunked
 
long long m_current_chunk_offset
 
long long m_current_chunk_size
 
XrdHttpProtocolprot
 

Member Enumeration Documentation

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 ( XrdHttpProtocol protinstance)
inline
virtual XrdHttpReq::~XrdHttpReq ( )
virtual

Member Function Documentation

void XrdHttpReq::appendOpaque ( XrdOucString s,
XrdSecEntity secent,
char *  hash,
time_t  tnow 
)
std::string XrdHttpReq::buildPartialHdr ( long long  bytestart,
long long  byteend,
long long  filesize,
char *  token 
)

Build a partial header for a multipart response.

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

Build the closing part for a multipart response.

void XrdHttpReq::clientMarshallReadAheadList ( int  nitems)
private
void XrdHttpReq::clientUnMarshallReadAheadList ( int  nitems)
private
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.

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.

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.

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.

void XrdHttpReq::getfhandle ( )
private
void XrdHttpReq::mapXrdErrorToHttpStatus ( )
private
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.

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

Parse the first line of the header.

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

Parse the header.

void XrdHttpReq::parseResource ( char *  url)
private
int XrdHttpReq::parseRWOp ( char *  )
private
int XrdHttpReq::PostProcessChecksum ( std::string &  digest_header)
private
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

int XrdHttpReq::ProcessHTTPReq ( )

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

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.

int XrdHttpReq::ReqReadV ( )

Prepare the buffers for sending a readv request.

virtual void XrdHttpReq::reset ( )
virtual

Member Data Documentation

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

Referenced by XrdHttpReq().

std::string XrdHttpReq::destination

The destination field specified in the req.

std::string XrdHttpReq::etext
char XrdHttpReq::fhandle[4]
long XrdHttpReq::fileflags
long XrdHttpReq::filemodtime
long long XrdHttpReq::filesize
bool XrdHttpReq::final

true -> final result

bool XrdHttpReq::fopened

Referenced by XrdHttpReq().

std::string XrdHttpReq::hdr2cgistr

Additional opaque info that may come from the hdr2cgi directive.

bool XrdHttpReq::headerok

Tells if we have finished reading the header.

Referenced by XrdHttpReq().

std::string XrdHttpReq::host

The host field specified in the req.

int XrdHttpReq::httpStatusCode
private
std::string XrdHttpReq::httpStatusText
private
int XrdHttpReq::iovL

byte count

int XrdHttpReq::iovN

array count

struct iovec* XrdHttpReq::iovP

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

pointer to data array

bool XrdHttpReq::keepalive
long long XrdHttpReq::length

Referenced by XrdHttpReq().

bool XrdHttpReq::m_appended_hdr2cgistr
long long XrdHttpReq::m_current_chunk_offset
private
long long XrdHttpReq::m_current_chunk_size
private
std::string XrdHttpReq::m_digest_header

The computed digest for the HTTP response header.

std::string XrdHttpReq::m_req_digest

The requested digest type.

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.

bool XrdHttpReq::m_transfer_encoding_chunked
private
XrdOucEnv* XrdHttpReq::opaque

The opaque data, after parsing.

Referenced by XrdHttpReq().

XrdHttpProtocol* XrdHttpReq::prot
private

Referenced by XrdHttpReq().

readahead_list* XrdHttpReq::ralist

Referenced by XrdHttpReq().

XrdOucString XrdHttpReq::redirdest
int XrdHttpReq::reqstate

State machine to talk to the bridge.

ReqType XrdHttpReq::request

The request we got.

std::string XrdHttpReq::requestverb
XrdOucString XrdHttpReq::resource

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

XrdOucString XrdHttpReq::resourceplusopaque

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

unsigned int XrdHttpReq::rwOpDone

To coordinate multipart responses across multiple calls.

unsigned int XrdHttpReq::rwOpPartialDone
std::vector<ReadWriteOp> XrdHttpReq::rwOps

The original list of multiple reads to perform.

std::vector<ReadWriteOp> XrdHttpReq::rwOps_split

The new list got from chunking the original req respecting the xrootd max sizes etc.

bool XrdHttpReq::sendcontinue
std::string XrdHttpReq::stringresp

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

long long XrdHttpReq::writtenbytes

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

Referenced by XrdHttpReq().

XErrorCode XrdHttpReq::xrderrcode
ClientRequest XrdHttpReq::xrdreq

The last issued xrd request, often pending.

XResponseType XrdHttpReq::xrdresp

The last response data we got.


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