XRootD
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. More...
 
int ChunkResp (const char *body, long long bodylen)
 Send a (potentially partial) body in a chunked response; invoking with NULL body. More...
 
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. More...
 
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. More...
 

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),
87 verb(req->requestverb), headers(req->allheaders) {
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;
109  trim(clienthost);
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 
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
std::string verb
XrdNetPMark * pmark
static XrdNetPMark * pmarkHandle
Packet marking handler pointer (assigned from the environment during the Config() call)
bool isHTTPS()
called via https
static bool tpcForwardCreds
If set to true, the HTTP TPC transfers will forward the credentials to redirected hosts.
XrdSecEntity SecEntity
Authentication area.
long long length
Definition: XrdHttpReq.hh:259
XrdOucString resource
The resource specified by the request, stripped of opaque data.
Definition: XrdHttpReq.hh:244
std::string requestverb
Definition: XrdHttpReq.hh:237
XrdOucEnv * opaque
The opaque data, after parsing.
Definition: XrdHttpReq.hh:246
XrdOucString resourceplusopaque
The resource specified by the request, including all the opaque data.
Definition: XrdHttpReq.hh:248
std::map< std::string, std::string > allheaders
Definition: XrdHttpReq.hh:241
char * Env(int &envlen)
Definition: XrdOucEnv.hh:48
const char * c_str() const
char * vorg
Entity's virtual organization(s)
Definition: XrdSecEntity.hh:71
char * moninfo
Information for monitoring.
Definition: XrdSecEntity.hh:76
char * host
Entity's host name dnr dependent.
Definition: XrdSecEntity.hh:70

References XrdOucString::c_str(), clientdn, clientgroups, clienthost, XrdOucEnv::Env(), headers, XrdSecEntity::host, XrdHttpProtocol::isHTTPS(), length, XrdHttpReq::length, XrdSecEntity::moninfo, mSciTag, XrdHttpReq::mScitag, XrdHttpReq::opaque, pmark, XrdHttpProtocol::pmarkHandle, resource, XrdHttpReq::resource, XrdHttpReq::resourceplusopaque, XrdHttpProtocol::SecEntity, tpcForwardCreds, XrdHttpProtocol::tpcForwardCreds, trim(), and XrdSecEntity::vorg.

+ 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 }
XrdLink * Link
The link we are bound to.

References XrdLink::Client(), and XrdHttpProtocol::Link.

+ Here is the call graph for this function:

◆ GetSecEntity()

const XrdSecEntity & XrdHttpExtReq::GetSecEntity ( ) const

Definition at line 80 of file XrdHttpExtHandler.cc.

81 {
82  return prot->SecEntity;
83 }

References XrdHttpProtocol::SecEntity.

◆ 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 TPC::TPCHandler::ProcessReq(), and Macaroons::Handler::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.

Referenced by XrdHttpExtReq().

◆ clientgroups

std::string XrdHttpExtReq::clientgroups

Definition at line 57 of file XrdHttpExtHandler.hh.

Referenced by XrdHttpExtReq().

◆ clienthost

std::string XrdHttpExtReq::clienthost

Definition at line 57 of file XrdHttpExtHandler.hh.

Referenced by XrdHttpExtReq().

◆ 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

◆ pmark

XrdNetPMark* XrdHttpExtReq::pmark

Definition at line 60 of file XrdHttpExtHandler.hh.

Referenced by XrdHttpExtReq().

◆ resource

std::string XrdHttpExtReq::resource

◆ 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 TPC::TPCHandler::ProcessReq().


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