xrootd
|
#include <XrdHttpReq.hh>
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::Result * | WaitResp (Bridge::Context &info, int wtime, const char *wtext) |
Result () | |
Constructor & Destructor. | |
virtual | ~Result () |
Public Attributes | |
std::vector< readahead_list > | ralist |
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. | |
XrdOucEnv * | opaque |
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} |
XrdHttpProtocol * | prot |
enum XrdHttpReq::ReqType |
|
inline |
|
virtual |
void XrdHttpReq::addCgi | ( | const std::string & | key, |
const std::string & | value | ||
) |
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.
|
private |
|
private |
|
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.
info | the context associated with the result. |
iovP | a 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. |
iovN | the number of elements in the iovec structure array. |
iovL | total number of data bytes that would be sent to the client. This is simply the sum of all the lengths in the iovec. |
final | True is this is the final result. Otherwise, this is a partial result (i.e. kXR_oksofar) and more data will result causing additional callbacks. |
info | the result context |
iovP | pointer to data array |
iovN | array count |
iovL | byte count |
final | true -> final result |
Implements XrdXrootd::Bridge::Result.
|
staticprivate |
Determine the XRootD-compliant checksum algorithm from the user digest string
userDigest | the string containing the digest names. e.g: adler32, md5;q=0.4, md5 |
xrootdChecksums | the 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 |
|
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).
info | the context associated with the result. |
Implements XrdXrootd::Bridge::Result.
|
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.
info | the context associated with the result. |
ecode | the "kXR" error code describing the nature of the error. The code is in host byte format. |
etext | a null terminated string describing the error in human terms |
info | the result context |
ecode | the "kXR" error code |
etext | associated error message |
Implements XrdXrootd::Bridge::Result.
|
staticprivate |
Extract a comma separated list of checksums+metadata into a vector
checksumList | the list like "0:sha1, 1:adler32, 2:md5" |
extractedChecksum | the vector with the elements {0:sha,1:adler32,2:md5} |
|
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).
info | the context associated with the result. |
dlen | total number of data bytes that would be sent to the client. |
info | the result context |
dlen | byte count |
Implements XrdXrootd::Bridge::Result.
|
private |
|
private |
|
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::parseFirstLine | ( | char * | line, |
int | len | ||
) |
Parse the first line of the header.
|
private |
int XrdHttpReq::parseLine | ( | char * | line, |
int | len | ||
) |
Parse the header.
|
private |
|
private |
|
private |
|
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 |
Redirect the client to another host:port.
The Redir() method is called when the client must be redirected to another host.
info | the context associated with the result. |
port | the port number in host byte format. |
hname | the DNS name of the host or IP address is IPV4 or IPV6 format (i.e. "n.n.n.n" or "[ipv6_addr]"). |
info | the result context |
port | the port number |
hname | the destination host |
Implements XrdXrootd::Bridge::Result.
int XrdHttpReq::ReqReadV | ( | const XrdHttpIOList & | cl | ) |
Prepare the buffers for sending a readv request.
|
virtual |
|
private |
|
private |
|
private |
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::filectime |
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.
|
private |
|
private |
int XrdHttpReq::iovL |
byte count
int XrdHttpReq::iovN |
array count
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
bool XrdHttpReq::keepalive |
long long XrdHttpReq::length |
Referenced by XrdHttpReq().
bool XrdHttpReq::m_appended_hdr2cgistr |
|
private |
|
private |
std::string XrdHttpReq::m_digest_header |
The computed digest for the HTTP response header.
XrdHttpChecksumHandler::XrdHttpChecksumRawPtr XrdHttpReq::m_req_cksum = nullptr |
The checksum that was ran for this request.
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.
|
private |
|
private |
|
private |
int XrdHttpReq::mScitag |
Referenced by XrdHttpReq().
XrdOucEnv* XrdHttpReq::opaque |
The opaque data, after parsing.
Referenced by XrdHttpReq().
|
private |
Referenced by XrdHttpReq().
std::vector<readahead_list> XrdHttpReq::ralist |
bool XrdHttpReq::readClosing |
XrdHttpReadRangeHandler XrdHttpReq::readRangeHandler |
Tracking the next ranges of data to read during GET.
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 |
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.