XRootD
Loading...
Searching...
No Matches
XrdHttpExtReq Class Reference

#include <XrdHttpExtHandler.hh>

Collaboration diagram for XrdHttpExtReq:

Public Member Functions

 XrdHttpExtReq (XrdHttpReq *req, XrdHttpProtocol *pr)
int BuffgetData (int blen, char **data, bool wait)
 Get a pointer to data read from the client, valid for up to blen bytes from the buffer. Returns the validity.
int ChunkResp (const char *body, long long bodylen)
 Send a (potentially partial) body in a chunked response; invoking with NULL body.
void GetClientID (std::string &clid)
const XrdSecEntityGetSecEntity () const
int SendSimpleResp (int code, const char *desc, const char *header_to_add, const char *body, long long bodylen)
 Sends a basic response. If the length is < 0 then it is calculated internally.
int StartChunkedResp (int code, const char *desc, const char *header_to_add)
 Starts a chunked response; body of request is sent over multiple parts using the SendChunkResp.

Public Attributes

std::string clientdn
std::string clientgroups
std::string clienthost
std::map< std::string, std::string > & headers
long long length
int mSciTag
XrdNetPMarkpmark
std::string resource
bool tpcForwardCreds = false
std::string verb

Detailed Description

Definition at line 47 of file XrdHttpExtHandler.hh.

Constructor & Destructor Documentation

◆ XrdHttpExtReq()

XrdHttpExtReq::XrdHttpExtReq ( XrdHttpReq * req,
XrdHttpProtocol * pr )

Definition at line 86 of file XrdHttpExtHandler.cc.

86 : prot(pr),
88 // Here we fill the request summary with all the fields we can
89 resource = req->resource.c_str();
90 int envlen = 0;
91
92 const char *p = nullptr;
93 if (req->opaque)
94 p = req->opaque->Env(envlen);
95 headers["xrd-http-query"] = p ? p:"";
96 p = req->resourceplusopaque.c_str();
97 headers["xrd-http-fullresource"] = p ? p:"";
98 headers["xrd-http-prot"] = prot->isHTTPS()?"https":"http";
99
100 // These fields usually identify the client that connected
101
102
103 if (prot->SecEntity.moninfo) {
104 clientdn = prot->SecEntity.moninfo;
105 trim(clientdn);
106 }
107 if (prot->SecEntity.host) {
108 clienthost = prot->SecEntity.host;
110 }
111 if (prot->SecEntity.vorg) {
112 clientgroups = prot->SecEntity.vorg;
114 }
115
116 // Get the packet marking handle and the client scitag from the XrdHttp layer
117 pmark = prot->pmarkHandle;
118 mSciTag = req->mScitag;
119
120 tpcForwardCreds = prot->tpcForwardCreds;
121
122 length = req->length;
123}
void trim(std::string &str)
Definition XrdHttpReq.cc:76
std::string clientdn
std::string clienthost
std::map< std::string, std::string > & headers
std::string clientgroups
std::string resource
XrdNetPMark * pmark
long long length
XrdOucString resource
The resource specified by the request, stripped of opaque data.
std::string requestverb
XrdOucEnv * opaque
The opaque data, after parsing.
XrdOucString resourceplusopaque
The resource specified by the request, including all the opaque data.
std::map< std::string, std::string > allheaders
char * Env(int &envlen)
Definition XrdOucEnv.hh:48
const char * c_str() const

References XrdOucString::c_str(), XrdOucEnv::Env(), headers, if(), length, XrdHttpReq::length, mSciTag, XrdHttpReq::mScitag, XrdHttpReq::opaque, pmark, resource, XrdHttpReq::resource, XrdHttpReq::resourceplusopaque, tpcForwardCreds, and verb.

Here is the call graph for this function:

Member Function Documentation

◆ BuffgetData()

int XrdHttpExtReq::BuffgetData ( int blen,
char ** data,
bool wait )

Get a pointer to data read from the client, valid for up to blen bytes from the buffer. Returns the validity.

Definition at line 65 of file XrdHttpExtHandler.cc.

65 {
66
67 if (!prot) return -1;
68 int nb = prot->BuffgetData(blen, data, wait);
69
70 return nb;
71}

Referenced by Macaroons::Handler::ProcessReq().

Here is the caller graph for this function:

◆ ChunkResp()

int XrdHttpExtReq::ChunkResp ( const char * body,
long long bodylen )

Send a (potentially partial) body in a chunked response; invoking with NULL body.

Definition at line 58 of file XrdHttpExtHandler.cc.

59{
60 if (!prot) return -1;
61
62 return prot->ChunkResp(body, bodylen);
63}

◆ GetClientID()

void XrdHttpExtReq::GetClientID ( std::string & clid)

Definition at line 73 of file XrdHttpExtHandler.cc.

74{
75 char buff[512];
76 prot->Link->Client(buff, sizeof(buff));
77 clid = buff;
78}

◆ GetSecEntity()

const XrdSecEntity & XrdHttpExtReq::GetSecEntity ( ) const

Definition at line 80 of file XrdHttpExtHandler.cc.

81{
82 return prot->SecEntity;
83}

◆ SendSimpleResp()

int XrdHttpExtReq::SendSimpleResp ( int code,
const char * desc,
const char * header_to_add,
const char * body,
long long bodylen )

Sends a basic response. If the length is < 0 then it is calculated internally.

Definition at line 31 of file XrdHttpExtHandler.cc.

32{
33 if (!prot) return -1;
34
35 // @FIXME
36 // - need this to circumvent missing API calls and keep ABI compatibility
37 // - when large files are returned we cannot return them in a single buffer
38 // @TODO: for XRootD 5.0 this two hidden calls should just be added to the external handler API and the code here can be removed
39
40 if ( code == 0 ) {
41 return prot->StartSimpleResp(200, desc, header_to_add, bodylen, true);
42 }
43
44 if ( code == 1 ) {
45 return prot->SendData(body, bodylen);
46 }
47
48 return prot->SendSimpleResp(code, desc, header_to_add, body, bodylen, true);
49}

Referenced by Macaroons::Handler::ProcessReq(), and TPC::TPCHandler::ProcessReq().

Here is the caller graph for this function:

◆ StartChunkedResp()

int XrdHttpExtReq::StartChunkedResp ( int code,
const char * desc,
const char * header_to_add )

Starts a chunked response; body of request is sent over multiple parts using the SendChunkResp.

Definition at line 51 of file XrdHttpExtHandler.cc.

52{
53 if (!prot) return -1;
54
55 return prot->StartChunkedResp(code, desc, header_to_add, -1, true);
56}

Member Data Documentation

◆ clientdn

std::string XrdHttpExtReq::clientdn

Definition at line 57 of file XrdHttpExtHandler.hh.

◆ clientgroups

std::string XrdHttpExtReq::clientgroups

Definition at line 57 of file XrdHttpExtHandler.hh.

◆ clienthost

std::string XrdHttpExtReq::clienthost

Definition at line 57 of file XrdHttpExtHandler.hh.

◆ headers

std::map<std::string, std::string>& XrdHttpExtReq::headers

◆ length

long long XrdHttpExtReq::length

Definition at line 58 of file XrdHttpExtHandler.hh.

Referenced by XrdHttpExtReq().

◆ mSciTag

int XrdHttpExtReq::mSciTag

Definition at line 64 of file XrdHttpExtHandler.hh.

Referenced by XrdHttpExtReq().

◆ pmark

XrdNetPMark* XrdHttpExtReq::pmark

Definition at line 60 of file XrdHttpExtHandler.hh.

Referenced by XrdHttpExtReq().

◆ resource

std::string XrdHttpExtReq::resource

Definition at line 54 of file XrdHttpExtHandler.hh.

Referenced by XrdHttpExtReq(), and Macaroons::Handler::ProcessReq().

◆ tpcForwardCreds

bool XrdHttpExtReq::tpcForwardCreds = false

Definition at line 62 of file XrdHttpExtHandler.hh.

Referenced by XrdHttpExtReq().

◆ verb

std::string XrdHttpExtReq::verb

Definition at line 54 of file XrdHttpExtHandler.hh.

Referenced by XrdHttpExtReq(), and TPC::TPCHandler::ProcessReq().


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