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

#include <XrdHttpReq.hh>

+ Inheritance diagram for XrdHttpReq:
+ Collaboration diagram for XrdHttpReq:

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 ()
 
void addCgi (const std::string &key, const std::string &value)
 
void appendOpaque (XrdOucString &s, XrdSecEntity *secent, char *hash, time_t tnow)
 
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.
 
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)
 
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 parseFirstLine (char *line, int len)
 Parse the first line of the header.
 
int parseLine (char *line, int len)
 Parse the header.
 
int ProcessHTTPReq ()
 
virtual bool Redir (XrdXrootd::Bridge::Context &info, int port, const char *hname)
 
int ReqReadV (const XrdHttpIOList &cl)
 Prepare the buffers for sending a readv request.
 
virtual void reset ()
 
const std::string & userAgent () const
 
- Public Member Functions inherited from XrdXrootd::Bridge::Result
 Result ()
 Constructor & Destructor.
 
virtual ~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)
 

Public Attributes

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

Detailed Description

Definition at line 71 of file XrdHttpReq.hh.

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 

Definition at line 219 of file XrdHttpReq.hh.

Constructor & Destructor Documentation

◆ XrdHttpReq()

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

Definition at line 166 of file XrdHttpReq.hh.

166 :
167 readRangeHandler(rcfg), keepalive(true) {
168
169 prot = protinstance;
170 length = 0;
171 //xmlbody = 0;
172 depth = 0;
173 opaque = 0;
174 writtenbytes = 0;
175 fopened = false;
176 headerok = false;
177 mScitag = -1;
178 };
long long length
bool headerok
Tells if we have finished reading the header.
long long writtenbytes
In a long write, we track where we have arrived.
XrdOucEnv * opaque
The opaque data, after parsing.
XrdHttpReadRangeHandler readRangeHandler
Tracking the next ranges of data to read during GET.

References depth, fopened, headerok, keepalive, length, mScitag, opaque, readRangeHandler, and writtenbytes.

◆ ~XrdHttpReq()

XrdHttpReq::~XrdHttpReq ( )
virtual

Definition at line 110 of file XrdHttpReq.cc.

110 {
111 //if (xmlbody) xmlFreeDoc(xmlbody);
112
113 reset();
114}
virtual void reset()

References reset().

+ Here is the call graph for this function:

Member Function Documentation

◆ addCgi()

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

Definition at line 786 of file XrdHttpReq.cc.

786 {
787 if (hdr2cgistr.length() > 0) {
788 hdr2cgistr.append("&");
789 }
790 hdr2cgistr.append(key);
791 hdr2cgistr.append("=");
792 hdr2cgistr.append(value);
793}
std::string hdr2cgistr
Additional opaque info that may come from the hdr2cgi directive.

References hdr2cgistr.

Referenced by parseLine().

+ Here is the caller graph for this function:

◆ appendOpaque()

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

Definition at line 629 of file XrdHttpReq.cc.

629 {
630
631 int l = 0;
632 char * p = 0;
633 if (opaque)
634 p = opaque->Env(l);
635
636 if (hdr2cgistr.empty() && (l < 2) && !hash) return;
637
638 // this works in most cases, except if the url already contains the xrdhttp tokens
639 s = s + "?";
640 if (!hdr2cgistr.empty()) {
641 char *s1 = quote(hdr2cgistr.c_str());
642 if (s1) {
643 s += s1;
644 free(s1);
645 }
646 }
647 if (p && (l > 1)) {
648 char *s1 = quote(p+1);
649 if (s1) {
650 if (!hdr2cgistr.empty()) {
651 s = s + "&";
652 }
653 s = s + s1;
654 free(s1);
655 }
656 }
657
658
659
660 if (hash) {
661 if (l > 1) s += "&";
662 s += "xrdhttptk=";
663 s += hash;
664
665 s += "&xrdhttptime=";
666 char buf[256];
667 sprintf(buf, "%lld", (long long) tnow);
668 s += buf;
669
670 if (secent) {
671 if (secent->name) {
672 s += "&xrdhttpname=";
673 char *s1 = quote(secent->name);
674 if (s1) {
675 s += s1;
676 free(s1);
677 }
678 }
679
680 if (secent->vorg) {
681 s += "&xrdhttpvorg=";
682 char *s1 = quote(secent->vorg);
683 if (s1) {
684 s += s1;
685 free(s1);
686 }
687 }
688
689 if (secent->host) {
690 s += "&xrdhttphost=";
691 char *s1 = quote(secent->host);
692 if (s1) {
693 s += s1;
694 free(s1);
695 }
696 }
697
698 if (secent->moninfo) {
699 s += "&xrdhttpdn=";
700 char *s1 = quote(secent->moninfo);
701 if (s1) {
702 s += s1;
703 free(s1);
704 }
705 }
706
707 if (secent->role) {
708 s += "&xrdhttprole=";
709 char *s1 = quote(secent->role);
710 if (s1) {
711 s += s1;
712 free(s1);
713 }
714 }
715
716 if (secent->grps) {
717 s += "&xrdhttpgrps=";
718 char *s1 = quote(secent->grps);
719 if (s1) {
720 s += s1;
721 free(s1);
722 }
723 }
724
725 if (secent->endorsements) {
726 s += "&xrdhttpendorsements=";
727 char *s1 = quote(secent->endorsements);
728 if (s1) {
729 s += s1;
730 free(s1);
731 }
732 }
733
734 if (secent->credslen) {
735 s += "&xrdhttpcredslen=";
736 char buf[16];
737 sprintf(buf, "%d", secent->credslen);
738 char *s1 = quote(buf);
739 if (s1) {
740 s += s1;
741 free(s1);
742 }
743 }
744
745 if (secent->credslen) {
746 if (secent->creds) {
747 s += "&xrdhttpcreds=";
748 // Apparently this string might be not 0-terminated (!)
749 char *zerocreds = strndup(secent->creds, secent->credslen);
750 if (zerocreds) {
751 char *s1 = quote(zerocreds);
752 if (s1) {
753 s += s1;
754 free(s1);
755 }
756 free(zerocreds);
757 }
758 }
759 }
760
761 }
762 }
763
764}
char * quote(const char *str)
char * vorg
Entity's virtual organization(s)
int credslen
Length of the 'creds' data.
char * creds
Raw entity credentials or cert.
char * grps
Entity's group name(s)
char * name
Entity's name.
char * role
Entity's role(s)
char * endorsements
Protocol specific endorsements.
char * moninfo
Information for monitoring.
char * host
Entity's host name dnr dependent.

References XrdSecEntity::creds, XrdSecEntity::credslen, XrdSecEntity::endorsements, XrdSecEntity::grps, hdr2cgistr, XrdSecEntity::host, XrdSecEntity::moninfo, XrdSecEntity::name, opaque, quote(), XrdSecEntity::role, and XrdSecEntity::vorg.

Referenced by ProcessHTTPReq(), and Redir().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildPartialHdr()

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

Build a partial header for a multipart response.

Definition at line 425 of file XrdHttpReq.cc.

425 {
426 std::ostringstream s;
427
428 s << "\r\n--" << token << "\r\n";
429 s << "Content-type: text/plain; charset=UTF-8\r\n";
430 s << "Content-range: bytes " << bytestart << "-" << byteend << "/" << fsz << "\r\n\r\n";
431
432 return s.str();
433}

◆ buildPartialHdrEnd()

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

Build the closing part for a multipart response.

Definition at line 435 of file XrdHttpReq.cc.

435 {
436 std::ostringstream s;
437
438 s << "\r\n--" << token << "--\r\n";
439
440 return s.str();
441}

◆ Data()

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.

Definition at line 443 of file XrdHttpReq.cc.

449 {
450
451 TRACE(REQ, " XrdHttpReq::Data! final=" << final);
452
453 this->xrdresp = kXR_ok;
454 this->iovP = iovP_;
455 this->iovN = iovN_;
456 this->iovL = iovL_;
457 this->final = final_;
458
459 if (PostProcessHTTPReq(final_)) reset();
460
461 return true;
462
463};
@ kXR_ok
Definition XProtocol.hh:899
#define TRACE(act, x)
Definition XrdTrace.hh:63
XResponseType xrdresp
The last response data we got.
int iovL
byte count
const struct iovec * iovP
The latest data chunks got from the xrd layer. These are valid only inside the callbacks!
int iovN
array count

References iovL, iovN, iovP, kXR_ok, reset(), TRACE, and xrdresp.

+ Here is the call graph for this function:

◆ Done()

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.

Definition at line 489 of file XrdHttpReq.cc.

489 {
490
491 TRACE(REQ, " XrdHttpReq::Done");
492
493 xrdresp = kXR_ok;
494
495 this->iovN = 0;
496
497 int r = PostProcessHTTPReq(true);
498 // Beware, we don't have to reset() if the result is 0
499 if (r) reset();
500 if (r < 0) return false;
501
502
503 return true;
504};

References iovN, kXR_ok, reset(), TRACE, and xrdresp.

+ Here is the call graph for this function:

◆ Error()

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.

Definition at line 506 of file XrdHttpReq.cc.

509 {
510
511 TRACE(REQ, " XrdHttpReq::Error");
512
514 xrderrcode = (XErrorCode) ecode;
515
516 if (etext_) {
517 char *s = escapeXML(etext_);
518 this->etext = s;
519 free(s);
520 }
521
522 if (PostProcessHTTPReq()) reset();
523
524 // If we are servicing a GET on a directory, it'll generate an error for the default
525 // OSS (we don't assume this is always true). Catch and suppress the error so we can instead
526 // generate a directory listing (if configured).
527 if ((request == rtGET) && (xrdreq.header.requestid == ntohs(kXR_open)) && (xrderrcode == kXR_isDirectory))
528 return true;
529
530 return false;
531};
XErrorCode
Definition XProtocol.hh:989
@ kXR_isDirectory
@ kXR_error
Definition XProtocol.hh:903
@ kXR_open
Definition XProtocol.hh:122
char * escapeXML(const char *str)
std::string etext
ReqType request
The request we got.
XErrorCode xrderrcode
ClientRequest xrdreq
The last issued xrd request, often pending.

References escapeXML(), etext, kXR_error, kXR_isDirectory, kXR_open, request, reset(), rtGET, TRACE, xrderrcode, xrdreq, and xrdresp.

+ Here is the call graph for this function:

◆ File()

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.

Definition at line 465 of file XrdHttpReq.cc.

467 {
468
469 // sendfile about to be sent by bridge for fetching data for GET:
470 // no https, no chunked+trailer, no multirange
471
472 //prot->SendSimpleResp(200, NULL, NULL, NULL, dlen);
473 int rc = info.Send(0, 0, 0, 0);
474 TRACE(REQ, " XrdHttpReq::File dlen:" << dlen << " send rc:" << rc);
475 bool start, finish;
476 // short read will be classed as error
477 if (rc) {
478 readRangeHandler.NotifyError();
479 return false;
480 }
481
482 if (readRangeHandler.NotifyReadResult(dlen, nullptr, start, finish) < 0)
483 return false;
484
485
486 return true;
487};
virtual int Send(const struct iovec *headP, int headN, const struct iovec *tailP, int tailN)

References readRangeHandler, XrdXrootd::Bridge::Context::Send(), and TRACE.

+ Here is the call graph for this function:

◆ 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.

Definition at line 94 of file XrdHttpReq.cc.

94 {
95 /*
96 * The document being in memory, it has no base per RFC 2396,
97 * and the "noname.xml" argument will serve as its base.
98 */
99 //xmlbody = xmlReadMemory(body, len, "noname.xml", NULL, 0);
100 //if (xmlbody == NULL) {
101 // fprintf(stderr, "Failed to parse document\n");
102 // return 1;
103 //}
104
105
106
107 return 1;
108}

Referenced by ProcessHTTPReq().

+ Here is the caller graph for this function:

◆ parseFirstLine()

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

Parse the first line of the header.

Definition at line 256 of file XrdHttpReq.cc.

256 {
257
258 char *key = line;
259
260 int pos;
261
262 // Do the naive parsing
263 if (!line) return -1;
264
265 // Look for the first space-delimited token
266 char *p = strchr((char *) line, (int) ' ');
267 if (!p) {
269 return -1;
270 }
271
272
273 pos = p - line;
274 // The first token cannot be too long
275 if (pos > MAX_TK_LEN - 1) {
277 return -2;
278 }
279
280 // The first space-delimited char cannot be the first one
281 // this allows to deal with the case when a client sends a first line that starts with a space " GET / HTTP/1.1"
282 if(pos == 0) {
284 return -4;
285 }
286
287 // the first token must be non empty
288 if (pos > 0) {
289 line[pos] = 0;
290 char *val = line + pos + 1;
291
292 // Here we are supposed to initialize whatever flag or variable that is needed
293 // by looking at the first token of the line
294
295 // The token is key
296 // The remainder is val, look for the resource
297 p = strchr((char *) val, (int) ' ');
298
299 if (!p) {
301 line[pos] = ' ';
302 return -3;
303 }
304
305 *p = '\0';
306 parseResource(val);
307
308 *p = ' ';
309
310 // Xlate the known header lines
311 if (!strcmp(key, "GET")) {
312 request = rtGET;
313 } else if (!strcmp(key, "HEAD")) {
314 request = rtHEAD;
315 } else if (!strcmp(key, "PUT")) {
316 request = rtPUT;
317 } else if (!strcmp(key, "POST")) {
318 request = rtPOST;
319 } else if (!strcmp(key, "PATCH")) {
321 } else if (!strcmp(key, "OPTIONS")) {
323 } else if (!strcmp(key, "DELETE")) {
325 } else if (!strcmp(key, "PROPFIND")) {
327
328 } else if (!strcmp(key, "MKCOL")) {
330
331 } else if (!strcmp(key, "MOVE")) {
332 request = rtMOVE;
333 } else {
335 }
336
337 requestverb = key;
338
339 // The last token should be the protocol. If it is HTTP/1.0, then
340 // keepalive is disabled by default.
341 if (!strcmp(p+1, "HTTP/1.0\r\n")) {
342 keepalive = false;
343 }
344 line[pos] = ' ';
345 }
346
347 return 0;
348}
#define MAX_TK_LEN
Definition XrdHttpReq.cc:65
std::string requestverb

References keepalive, MAX_TK_LEN, request, requestverb, rtDELETE, rtGET, rtHEAD, rtMalformed, rtMKCOL, rtMOVE, rtOPTIONS, rtPATCH, rtPOST, rtPROPFIND, rtPUT, and rtUnknown.

◆ parseLine()

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

Parse the header.

Definition at line 116 of file XrdHttpReq.cc.

116 {
117
118 char *key = line;
119 int pos;
120
121 // Do the parsing
122 if (!line) return -1;
123
124
125 char *p = strchr((char *) line, (int) ':');
126 if (!p) {
127
129 return -1;
130 }
131
132 pos = (p - line);
133 if (pos > (MAX_TK_LEN - 1)) {
134
136 return -2;
137 }
138
139 if (pos > 0) {
140 line[pos] = 0;
141 char *val = line + pos + 1;
142
143 // Trim left
144 while ( (!isgraph(*val) || (!*val)) && (val < line+len)) val++;
145
146 // We memorize the headers also as a string
147 // because external plugins may need to process it differently
148 std::string ss = val;
149 if(ss.length() >= 2 && ss.substr(ss.length() - 2, 2) != "\r\n") {
151 return -3;
152 }
153 trim(ss);
154 allheaders[key] = ss;
155
156 // Here we are supposed to initialize whatever flag or variable that is needed
157 // by looking at the first token of the line
158 // The token is key
159 // The value is val
160
161 // Screen out the needed header lines
162 if (!strcasecmp(key, "connection")) {
163
164 if (!strcasecmp(val, "Keep-Alive\r\n")) {
165 keepalive = true;
166 } else if (!strcasecmp(val, "close\r\n")) {
167 keepalive = false;
168 }
169
170 } else if (!strcasecmp(key, "host")) {
171 parseHost(val);
172 } else if (!strcasecmp(key, "range")) {
173 // (rfc2616 14.35.1) says if Range header contains any range
174 // which is syntactically invalid the Range header should be ignored.
175 // Therefore no need for the range handler to report an error.
176 readRangeHandler.ParseContentRange(val);
177 } else if (!strcasecmp(key, "content-length")) {
178 length = atoll(val);
179
180 } else if (!strcasecmp(key, "destination")) {
181 destination.assign(val, line+len-val);
183 } else if (!strcasecmp(key, "want-digest")) {
184 m_req_digest.assign(val, line + len - val);
186 //Transform the user requests' want-digest to lowercase
187 std::transform(m_req_digest.begin(),m_req_digest.end(),m_req_digest.begin(),::tolower);
188 } else if (!strcasecmp(key, "depth")) {
189 depth = -1;
190 if (strcmp(val, "infinity"))
191 depth = atoll(val);
192
193 } else if (!strcasecmp(key, "expect") && strstr(val, "100-continue")) {
194 sendcontinue = true;
195 } else if (!strcasecmp(key, "te") && strstr(val, "trailers")) {
196 m_trailer_headers = true;
197 } else if (!strcasecmp(key, "transfer-encoding") && strstr(val, "chunked")) {
198 m_transfer_encoding_chunked = true;
199 } else if (!strcasecmp(key, "x-transfer-status") && strstr(val, "true")) {
200 m_transfer_encoding_chunked = true;
201 m_status_trailer = true;
202 } else if (!strcasecmp(key, "scitag")) {
203 if(prot->pmarkHandle != nullptr) {
204 parseScitag(val);
205 }
206 } else if (!strcasecmp(key, "user-agent")) {
207 m_user_agent = val;
208 trim(m_user_agent);
209 } else {
210 // Some headers need to be translated into "local" cgi info.
211 auto it = std::find_if(prot->hdr2cgimap.begin(), prot->hdr2cgimap.end(),[key](const auto & item) {
212 return !strcasecmp(key,item.first.c_str());
213 });
214 if (it != prot->hdr2cgimap.end() && (opaque ? (0 == opaque->Get(it->second.c_str())) : true)) {
215 std::string s;
216 s.assign(val, line+len-val);
217 trim(s);
218 addCgi(it->second,s);
219 }
220 }
221
222
223 line[pos] = ':';
224 }
225
226 return 0;
227}
void trim(std::string &str)
Definition XrdHttpReq.cc:76
std::string destination
The destination field specified in the req.
std::string m_req_digest
The requested digest type.
std::map< std::string, std::string > allheaders
void addCgi(const std::string &key, const std::string &value)
bool sendcontinue

References addCgi(), allheaders, depth, destination, keepalive, length, m_req_digest, MAX_TK_LEN, opaque, readRangeHandler, request, rtMalformed, sendcontinue, and trim().

+ Here is the call graph for this function:

◆ ProcessHTTPReq()

int XrdHttpReq::ProcessHTTPReq ( )

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

If we have to add extra header information, add it here.

Definition at line 928 of file XrdHttpReq.cc.

928 {
929
930 kXR_int32 l;
931
933 if (!m_appended_hdr2cgistr && !hdr2cgistr.empty()) {
934 const char *p = strchr(resourceplusopaque.c_str(), '?');
935 if (p) {
936 resourceplusopaque.append("&");
937 } else {
938 resourceplusopaque.append("?");
939 }
940
941 char *q = quote(hdr2cgistr.c_str());
942 resourceplusopaque.append(q);
943 if (TRACING(TRACE_DEBUG)) {
944 // The obfuscation of "authz" will only be done if the server http.header2cgi config contains something that maps a header to this "authz" cgi.
945 // Unfortunately the obfuscation code will be called no matter what is configured in http.header2cgi.
946 std::string header2cgistrObf = obfuscateAuth(hdr2cgistr);
947
948 TRACEI(DEBUG, "Appended header fields to opaque info: '"
949 << header2cgistrObf.c_str() << "'");
950
951 }
952 // We assume that anything appended to the CGI str should also
953 // apply to the destination in case of a MOVE.
954 if (strchr(destination.c_str(), '?')) destination.append("&");
955 else destination.append("?");
956 destination.append(q);
957
958 free(q);
960 }
961
962 // Verify if we have an external handler for this request
963 if (reqstate == 0) {
964 XrdHttpExtHandler *exthandler = prot->FindMatchingExtHandler(*this);
965 if (exthandler) {
966 XrdHttpExtReq xreq(this, prot);
967 int r = exthandler->ProcessReq(xreq);
968 reset();
969 if (!r) return 1; // All went fine, response sent
970 if (r < 0) return -1; // There was a hard error... close the connection
971
972 return 1; // There was an error and a response was sent
973 }
974 }
975
976 //
977 // Here we process the request locally
978 //
979
980 switch (request) {
983 {
984 prot->SendSimpleResp(400, NULL, NULL, (char *) "Request unknown", 0, false);
985 reset();
986 return -1;
987 }
989 {
990 prot->SendSimpleResp(400, NULL, NULL, (char *) "Request malformed", 0, false);
991 reset();
992 return -1;
993 }
995 {
996 if (reqstate == 0) {
997 // Always start with Stat; in the case of a checksum request, we'll have a follow-up query
998 if (prot->doStat((char *) resourceplusopaque.c_str())) {
999 prot->SendSimpleResp(404, NULL, NULL, (char *) "Could not run request.", 0, false);
1000 return -1;
1001 }
1002 return 0;
1003 } else {
1004 const char *opaque = strchr(resourceplusopaque.c_str(), '?');
1005 // Note that doChksum requires that the memory stays alive until the callback is invoked.
1007
1008 m_req_cksum = prot->cksumHandler.getChecksumToRun(m_req_digest);
1009 if(!m_req_cksum) {
1010 // No HTTP IANA checksums have been configured by the server admin, return a "METHOD_NOT_ALLOWED" error
1011 prot->SendSimpleResp(403, NULL, NULL, (char *) "No HTTP-IANA compatible checksums have been configured.", 0, false);
1012 return -1;
1013 }
1014 if (!opaque) {
1015 m_resource_with_digest += "?cks.type=";
1016 m_resource_with_digest += m_req_cksum->getXRootDConfigDigestName().c_str();
1017 } else {
1018 m_resource_with_digest += "&cks.type=";
1019 m_resource_with_digest += m_req_cksum->getXRootDConfigDigestName().c_str();
1020 }
1021 if (prot->doChksum(m_resource_with_digest) < 0) {
1022 // In this case, the Want-Digest header was set and PostProcess gave the go-ahead to do a checksum.
1023 prot->SendSimpleResp(500, NULL, NULL, (char *) "Failed to create initial checksum request.", 0, false);
1024 return -1;
1025 }
1026 return 1;
1027 }
1028 }
1029 case XrdHttpReq::rtGET:
1030 {
1031 int retval = keepalive ? 1 : -1; // reset() clears keepalive
1032
1033 if (resource.beginswith("/static/")) {
1034
1035 // This is a request for a /static resource
1036 // If we have to use the embedded ones then we return the ones in memory as constants
1037
1038 // The sysadmin can always redirect the request to another host that
1039 // contains his static resources
1040
1041 // We also allow xrootd to preread from the local disk all the files
1042 // that have to be served as static resources.
1043
1044 if (prot->embeddedstatic) {
1045
1046 // Default case: the icon and the css of the HTML rendering of XrdHttp
1047 if (resource == "/static/css/xrdhttp.css") {
1048 prot->SendSimpleResp(200, NULL, NULL, (char *) static_css_xrdhttp_css, static_css_xrdhttp_css_len, keepalive);
1049 reset();
1050 return retval;
1051 }
1052 if (resource == "/static/icons/xrdhttp.ico") {
1053 prot->SendSimpleResp(200, NULL, NULL, (char *) favicon_ico, favicon_ico_len, keepalive);
1054 reset();
1055 return retval;
1056 }
1057
1058 }
1059
1060 // If we are here then none of the embedded resources match (or they are disabled)
1061 // We may have to redirect to a host that is supposed to serve the static resources
1062 if (prot->staticredir) {
1063
1064 XrdOucString s = "Location: ";
1065 s.append(prot->staticredir);
1066
1067 if (s.endswith('/'))
1068 s.erasefromend(1);
1069
1070 s.append(resource);
1071 appendOpaque(s, 0, 0, 0);
1072
1073 prot->SendSimpleResp(302, NULL, (char *) s.c_str(), 0, 0, false);
1074 return -1;
1075
1076
1077 } else {
1078
1079 // We lookup the requested path in a hash containing the preread files
1080 if (prot->staticpreload) {
1081 XrdHttpProtocol::StaticPreloadInfo *mydata = prot->staticpreload->Find(resource.c_str());
1082 if (mydata) {
1083 prot->SendSimpleResp(200, NULL, NULL, (char *) mydata->data, mydata->len, keepalive);
1084 reset();
1085 return retval;
1086 }
1087 }
1088
1089 }
1090
1091
1092 }
1093
1094 // The reqstate parameter basically moves us through a simple state machine.
1095 // To optimize things, we start off by opening the file; if it turns out to be a directory, then
1096 // we close the file handle and switch to doing a HTML-based rendering of the directory. This
1097 // avoids needing to always to do "stat" first to determine the next step (since the file-open also
1098 // does a "stat").
1099 // - 0: Perform an open on the resource
1100 // - 1: Perform a checksum request on the resource (only if requested in header; otherwise skipped)
1101 // - 2: Perform a close (for dirlist only)
1102 // - 3: Perform a dirlist.
1103 // - 4+: Reads from file; if at end, perform a close.
1104 switch (reqstate) {
1105 case 0: // Open the path for reading.
1106 {
1107 memset(&xrdreq, 0, sizeof (ClientRequest));
1108 xrdreq.open.requestid = htons(kXR_open);
1109 l = resourceplusopaque.length() + 1;
1110 xrdreq.open.dlen = htonl(l);
1111 xrdreq.open.mode = 0;
1112 xrdreq.open.options = htons(kXR_retstat | kXR_open_read);
1113
1114 if (!prot->Bridge->Run((char *) &xrdreq, (char *) resourceplusopaque.c_str(), l)) {
1115 prot->SendSimpleResp(404, NULL, NULL, (char *) "Could not run request.", 0, false);
1116 return -1;
1117 }
1118
1119 // Prepare to chunk up the request
1120 writtenbytes = 0;
1121
1122 // We want to be invoked again after this request is finished
1123 return 0;
1124 }
1125 case 1: // Checksum request
1126 if (!(fileflags & kXR_isDir) && !m_req_digest.empty()) {
1127 // In this case, the Want-Digest header was set.
1128 bool has_opaque = strchr(resourceplusopaque.c_str(), '?');
1129 // Note that doChksum requires that the memory stays alive until the callback is invoked.
1130 m_req_cksum = prot->cksumHandler.getChecksumToRun(m_req_digest);
1131 if(!m_req_cksum) {
1132 // No HTTP IANA checksums have been configured by the server admin, return a "METHOD_NOT_ALLOWED" error
1133 prot->SendSimpleResp(403, NULL, NULL, (char *) "No HTTP-IANA compatible checksums have been configured.", 0, false);
1134 return -1;
1135 }
1137 if (has_opaque) {
1138 m_resource_with_digest += "&cks.type=";
1139 m_resource_with_digest += m_req_cksum->getXRootDConfigDigestName().c_str();
1140 } else {
1141 m_resource_with_digest += "?cks.type=";
1142 m_resource_with_digest += m_req_cksum->getXRootDConfigDigestName().c_str();
1143 }
1144 if (prot->doChksum(m_resource_with_digest) < 0) {
1145 prot->SendSimpleResp(500, NULL, NULL, (char *) "Failed to start internal checksum request to satisfy Want-Digest header.", 0, false);
1146 return -1;
1147 }
1148 return 0;
1149 } else {
1150 TRACEI(DEBUG, "No checksum requested; skipping to request state 2");
1151 reqstate += 1;
1152 }
1153 // fallthrough
1154 case 2: // Close file handle for directory
1155 if ((fileflags & kXR_isDir) && fopened) {
1156 memset(&xrdreq, 0, sizeof (ClientRequest));
1157 xrdreq.close.requestid = htons(kXR_close);
1158 memcpy(xrdreq.close.fhandle, fhandle, 4);
1159
1160 if (!prot->Bridge->Run((char *) &xrdreq, 0, 0)) {
1161 mapXrdErrorToHttpStatus();
1162 sendFooterError("Could not run close request on the bridge");
1163 return -1;
1164 }
1165 return 0;
1166 } else {
1167 reqstate += 1;
1168 }
1169 // fallthrough
1170 case 3: // List directory
1171 if (fileflags & kXR_isDir) {
1172 if (prot->listdeny) {
1173 prot->SendSimpleResp(503, NULL, NULL, (char *) "Listings are disabled.", 0, false);
1174 return -1;
1175 }
1176
1177 if (prot->listredir) {
1178 XrdOucString s = "Location: ";
1179 s.append(prot->listredir);
1180
1181 if (s.endswith('/'))
1182 s.erasefromend(1);
1183
1184 s.append(resource);
1185 appendOpaque(s, 0, 0, 0);
1186
1187 prot->SendSimpleResp(302, NULL, (char *) s.c_str(), 0, 0, false);
1188 return -1;
1189 }
1190
1191 std::string res;
1192 res = resourceplusopaque.c_str();
1193
1194 // --------- DIRLIST
1195 memset(&xrdreq, 0, sizeof (ClientRequest));
1196 xrdreq.dirlist.requestid = htons(kXR_dirlist);
1197 xrdreq.dirlist.options[0] = kXR_dstat;
1198 l = res.length() + 1;
1199 xrdreq.dirlist.dlen = htonl(l);
1200
1201 if (!prot->Bridge->Run((char *) &xrdreq, (char *) res.c_str(), l)) {
1202 mapXrdErrorToHttpStatus();
1203 prot->SendSimpleResp(httpStatusCode, NULL, NULL, httpStatusText.c_str(), httpStatusText.length(), false);
1204 sendFooterError("Could not run listing request on the bridge");
1205 return -1;
1206 }
1207
1208 // We don't want to be invoked again after this request is finished
1209 return 1;
1210 }
1211 else {
1212 reqstate += 1;
1213 }
1214 // fallthrough
1215 case 4:
1216 {
1217 auto retval = ReturnGetHeaders();
1218 if (retval) {
1219 return retval;
1220 }
1221 }
1222 // fallthrough
1223 default: // Read() or Close(); reqstate is 4+
1224 {
1225 const XrdHttpIOList &readChunkList = readRangeHandler.NextReadList();
1226
1227 // Close() if we have finished, otherwise read the next chunk
1228
1229 // --------- CLOSE
1230 if ( readChunkList.empty() )
1231 {
1232
1233 memset(&xrdreq, 0, sizeof (ClientRequest));
1234 xrdreq.close.requestid = htons(kXR_close);
1235 memcpy(xrdreq.close.fhandle, fhandle, 4);
1236
1237 if (!prot->Bridge->Run((char *) &xrdreq, 0, 0)) {
1238 TRACEI(REQ, " Failed to run close request on the bridge.");
1239 // Note: we have already completed the request and sent the data to the client.
1240 // Hence, there's no need to send an error. However, since the bridge is potentially
1241 // in a bad state, we close the TCP socket to force the client to reconnect.
1242 return -1;
1243 }
1244
1245 // We have finished
1246 readClosing = true;
1247 return 1;
1248
1249 }
1250 // --------- READ or READV
1251
1252 if ( readChunkList.size() == 1 ) {
1253 // Use a read request for single range
1254
1255 long l;
1256 long long offs;
1257
1258 // --------- READ
1259 memset(&xrdreq, 0, sizeof (xrdreq));
1260 xrdreq.read.requestid = htons(kXR_read);
1261 memcpy(xrdreq.read.fhandle, fhandle, 4);
1262 xrdreq.read.dlen = 0;
1263
1264 offs = readChunkList[0].offset;
1265 l = readChunkList[0].size;
1266
1267 xrdreq.read.offset = htonll(offs);
1268 xrdreq.read.rlen = htonl(l);
1269
1270 // If we are using HTTPS or if the client requested trailers, or if the
1271 // read concerns a multirange reponse, disable sendfile
1272 // (in the latter two cases, the extra framing is only done in PostProcessHTTPReq)
1273 if (prot->ishttps || (m_transfer_encoding_chunked && m_trailer_headers) ||
1274 !readRangeHandler.isSingleRange()) {
1275 if (!prot->Bridge->setSF((kXR_char *) fhandle, false)) {
1276 TRACE(REQ, " XrdBridge::SetSF(false) failed.");
1277
1278 }
1279 }
1280
1281
1282
1283 if (l <= 0) {
1284 if (l < 0) {
1285 TRACE(ALL, " Data sizes mismatch.");
1286 return -1;
1287 }
1288 else {
1289 TRACE(ALL, " No more bytes to send.");
1290 reset();
1291 return 1;
1292 }
1293 }
1294
1295 if ((offs >= filesize) || (offs+l > filesize)) {
1296 httpStatusCode = 416;
1297 httpStatusText = "Range Not Satisfiable";
1298 std::stringstream ss;
1299 ss << "Requested range " << l << "@" << offs << " is past the end of file (" << filesize << ")";
1300 sendFooterError(ss.str());
1301 return -1;
1302 }
1303
1304 if (!prot->Bridge->Run((char *) &xrdreq, 0, 0)) {
1305 mapXrdErrorToHttpStatus();
1306 sendFooterError("Could not run read request on the bridge");
1307 return -1;
1308 }
1309 } else {
1310 // --------- READV
1311
1312 length = ReqReadV(readChunkList);
1313
1314 if (!prot->Bridge->Run((char *) &xrdreq, (char *) &ralist[0], length)) {
1315 mapXrdErrorToHttpStatus();
1316 sendFooterError("Could not run ReadV request on the bridge");
1317 return -1;
1318 }
1319
1320 }
1321
1322 // We want to be invoked again after this request is finished
1323 return 0;
1324 } // case 3+
1325
1326 } // switch (reqstate)
1327
1328
1329 } // case XrdHttpReq::rtGET
1330
1331 case XrdHttpReq::rtPUT:
1332 {
1333 //if (prot->ishttps) {
1334 //prot->SendSimpleResp(501, NULL, NULL, (char *) "HTTPS not supported yet for direct writing. Sorry.", 0);
1335 //return -1;
1336 //}
1337
1338 if (!fopened) {
1339
1340 // --------- OPEN for write!
1341 memset(&xrdreq, 0, sizeof (ClientRequest));
1342 xrdreq.open.requestid = htons(kXR_open);
1343 l = resourceplusopaque.length() + 1;
1344 xrdreq.open.dlen = htonl(l);
1345 xrdreq.open.mode = htons(kXR_ur | kXR_uw | kXR_gw | kXR_gr | kXR_or);
1346 if (! XrdHttpProtocol::usingEC)
1347 xrdreq.open.options = htons(kXR_mkpath | kXR_open_wrto | kXR_delete);
1348 else
1349 xrdreq.open.options = htons(kXR_mkpath | kXR_open_wrto | kXR_new);
1350
1351 if (!prot->Bridge->Run((char *) &xrdreq, (char *) resourceplusopaque.c_str(), l)) {
1352 prot->SendSimpleResp(404, NULL, NULL, (char *) "Could not run request.", 0, keepalive);
1353 return -1;
1354 }
1355
1356
1357 // We want to be invoked again after this request is finished
1358 // Only if there is data to fetch from the socket or there will
1359 // never be more data
1360 if (prot->BuffUsed() > 0 || (length == 0 && !sendcontinue))
1361 return 0;
1362
1363 return 1;
1364
1365 } else {
1366
1367 if (m_transfer_encoding_chunked) {
1368 if (m_current_chunk_size == m_current_chunk_offset) {
1369 // Chunk has been consumed; we now must process the CRLF.
1370 // Note that we don't support trailer headers.
1371 if (prot->BuffUsed() < 2) return 1;
1372 if (prot->myBuffStart[0] != '\r' || prot->myBuffStart[1] != '\n') {
1373 prot->SendSimpleResp(400, NULL, NULL, (char *) "Invalid trailing chunk encoding.", 0, keepalive);
1374 return -1;
1375 }
1376 prot->BuffConsume(2);
1377 if (m_current_chunk_size == 0) {
1378 // All data has been sent. Turn off chunk processing and
1379 // set the bytes written and length appropriately; on next callback,
1380 // we will hit the close() block below.
1381 m_transfer_encoding_chunked = false;
1383 return ProcessHTTPReq();
1384 }
1385 m_current_chunk_size = -1;
1386 m_current_chunk_offset = 0;
1387 // If there is more data, we try to process the next chunk; otherwise, return
1388 if (!prot->BuffUsed()) return 1;
1389 }
1390 if (-1 == m_current_chunk_size) {
1391
1392 // Parse out the next chunk size.
1393 long long idx = 0;
1394 bool found_newline = false;
1395 // Set a maximum size of chunk we will allow
1396 // Nginx sets this to "NGX_MAX_OFF_T_VALUE", which is 9223372036854775807 (a some crazy number)
1397 // We set it to 1TB, which is 1099511627776
1398 // This is to prevent a malicious client from sending a very large chunk size
1399 // or a malformed chunk request.
1400 // 1TB in base-16 is 0x40000000000, so only allow 11 characters, plus the CRLF
1401 long long max_chunk_size_chars = std::min(static_cast<long long>(prot->BuffUsed()), static_cast<long long>(13));
1402 for (; idx < max_chunk_size_chars; idx++) {
1403 if (prot->myBuffStart[idx] == '\n') {
1404 found_newline = true;
1405 break;
1406 }
1407 }
1408 // If we found a new line, but it is the first character in the buffer (no chunk length)
1409 // or if the previous character is not a CR.
1410 if (found_newline && ((idx == 0) || prot->myBuffStart[idx-1] != '\r')) {
1411 prot->SendSimpleResp(400, NULL, NULL, (char *)"Invalid chunked encoding", 0, false);
1412 TRACE(REQ, "XrdHTTP PUT: Sending invalid chunk encoding. Start of chunk should have had a length, followed by a CRLF.");
1413 return -1;
1414 }
1415 if (found_newline) {
1416 char *endptr = NULL;
1417 std::string line_contents(prot->myBuffStart, idx);
1418 long long chunk_contents = strtol(line_contents.c_str(), &endptr, 16);
1419 // Chunk sizes can be followed by trailer information or CRLF
1420 if (*endptr != ';' && *endptr != '\r') {
1421 prot->SendSimpleResp(400, NULL, NULL, (char *)"Invalid chunked encoding", 0, false);
1422 TRACE(REQ, "XrdHTTP PUT: Sending invalid chunk encoding. Chunk size was not followed by a ';' or CR." << __LINE__);
1423 return -1;
1424 }
1425 m_current_chunk_size = chunk_contents;
1426 m_current_chunk_offset = 0;
1427 prot->BuffConsume(idx + 1);
1428 TRACE(REQ, "XrdHTTP PUT: next chunk from client will be " << m_current_chunk_size << " bytes");
1429 } else {
1430 // Need more data!
1431 return 1;
1432 }
1433 }
1434
1435 if (m_current_chunk_size == 0) {
1436 // All data has been sent. Invoke this routine again immediately to process CRLF
1437 return ProcessHTTPReq();
1438 } else {
1439 // At this point, we have a chunk size defined and should consume payload data
1440 memset(&xrdreq, 0, sizeof (xrdreq));
1441 xrdreq.write.requestid = htons(kXR_write);
1442 memcpy(xrdreq.write.fhandle, fhandle, 4);
1443
1444 long long chunk_bytes_remaining = m_current_chunk_size - m_current_chunk_offset;
1445 long long bytes_to_write = std::min(static_cast<long long>(prot->BuffUsed()),
1446 chunk_bytes_remaining);
1447
1448 xrdreq.write.offset = htonll(writtenbytes);
1449 xrdreq.write.dlen = htonl(bytes_to_write);
1450
1451 TRACEI(REQ, "XrdHTTP PUT: Writing chunk of size " << bytes_to_write << " starting with '" << *(prot->myBuffStart) << "'" << " with " << chunk_bytes_remaining << " bytes remaining in the chunk");
1452 if (!prot->Bridge->Run((char *) &xrdreq, prot->myBuffStart, bytes_to_write)) {
1453 mapXrdErrorToHttpStatus();
1454 sendFooterError("Could not run write request on the bridge");
1455 return -1;
1456 }
1457 // If there are more bytes in the buffer, then immediately call us after the
1458 // write is finished; otherwise, wait for data.
1459 return (prot->BuffUsed() > chunk_bytes_remaining) ? 0 : 1;
1460 }
1461 } else if (writtenbytes < length) {
1462
1463
1464 // --------- WRITE
1465 memset(&xrdreq, 0, sizeof (xrdreq));
1466 xrdreq.write.requestid = htons(kXR_write);
1467 memcpy(xrdreq.write.fhandle, fhandle, 4);
1468
1469 long long bytes_to_read = std::min(static_cast<long long>(prot->BuffUsed()),
1471
1472 xrdreq.write.offset = htonll(writtenbytes);
1473 xrdreq.write.dlen = htonl(bytes_to_read);
1474
1475 TRACEI(REQ, "Writing " << bytes_to_read);
1476 if (!prot->Bridge->Run((char *) &xrdreq, prot->myBuffStart, bytes_to_read)) {
1477 mapXrdErrorToHttpStatus();
1478 sendFooterError("Could not run write request on the bridge");
1479 return -1;
1480 }
1481
1482 if (writtenbytes + prot->BuffUsed() >= length)
1483 // Trigger an immediate recall after this request has finished
1484 return 0;
1485 else
1486 // We want to be invoked again after this request is finished
1487 // only if there is pending data
1488 return 1;
1489
1490
1491
1492 } else {
1493
1494 // --------- CLOSE
1495 memset(&xrdreq, 0, sizeof (ClientRequest));
1496 xrdreq.close.requestid = htons(kXR_close);
1497 memcpy(xrdreq.close.fhandle, fhandle, 4);
1498
1499
1500 if (!prot->Bridge->Run((char *) &xrdreq, 0, 0)) {
1501 mapXrdErrorToHttpStatus();
1502 sendFooterError("Could not run close request on the bridge");
1503 return -1;
1504 }
1505
1506 // We have finished
1507 return 1;
1508
1509 }
1510
1511 }
1512
1513 break;
1514
1515 }
1517 {
1518 prot->SendSimpleResp(200, NULL, (char *) "DAV: 1\r\nDAV: <http://apache.org/dav/propset/fs/1>\r\nAllow: HEAD,GET,PUT,PROPFIND,DELETE,OPTIONS", NULL, 0, keepalive);
1519 bool ret_keepalive = keepalive; // reset() clears keepalive
1520 reset();
1521 return ret_keepalive ? 1 : -1;
1522 }
1524 {
1525
1526
1527 switch (reqstate) {
1528
1529 case 0: // Stat()
1530 {
1531
1532
1533 // --------- STAT is always the first step
1534 memset(&xrdreq, 0, sizeof (ClientRequest));
1535 xrdreq.stat.requestid = htons(kXR_stat);
1536 std::string s = resourceplusopaque.c_str();
1537
1538
1539 l = resourceplusopaque.length() + 1;
1540 xrdreq.stat.dlen = htonl(l);
1541
1542 if (!prot->Bridge->Run((char *) &xrdreq, (char *) resourceplusopaque.c_str(), l)) {
1543 prot->SendSimpleResp(501, NULL, NULL, (char *) "Could not run request.", 0, false);
1544 return -1;
1545 }
1546
1547 // We need to be invoked again to complete the request
1548 return 0;
1549 }
1550 default:
1551
1552 if (fileflags & kXR_isDir) {
1553 // --------- RMDIR
1554 memset(&xrdreq, 0, sizeof (ClientRequest));
1555 xrdreq.rmdir.requestid = htons(kXR_rmdir);
1556
1557 std::string s = resourceplusopaque.c_str();
1558
1559 l = s.length() + 1;
1560 xrdreq.rmdir.dlen = htonl(l);
1561
1562 if (!prot->Bridge->Run((char *) &xrdreq, (char *) s.c_str(), l)) {
1563 prot->SendSimpleResp(501, NULL, NULL, (char *) "Could not run rmdir request.", 0, false);
1564 return -1;
1565 }
1566 } else {
1567 // --------- DELETE
1568 memset(&xrdreq, 0, sizeof (ClientRequest));
1569 xrdreq.rm.requestid = htons(kXR_rm);
1570
1571 std::string s = resourceplusopaque.c_str();
1572
1573 l = s.length() + 1;
1574 xrdreq.rm.dlen = htonl(l);
1575
1576 if (!prot->Bridge->Run((char *) &xrdreq, (char *) s.c_str(), l)) {
1577 prot->SendSimpleResp(501, NULL, NULL, (char *) "Could not run rm request.", 0, false);
1578 return -1;
1579 }
1580 }
1581
1582
1583 // We don't want to be invoked again after this request is finished
1584 return 1;
1585
1586 }
1587
1588
1589
1590 }
1592 {
1593 prot->SendSimpleResp(501, NULL, NULL, (char *) "Request not supported yet.", 0, false);
1594
1595 return -1;
1596 }
1598 {
1599
1600
1601
1602 switch (reqstate) {
1603
1604 case 0: // Stat() and add the current item to the list of the things to send
1605 {
1606
1607 if (length > 0) {
1608 TRACE(REQ, "Reading request body " << length << " bytes.");
1609 char *p = 0;
1610 // We have to specifically read all the request body
1611
1612 if (prot->BuffgetData(length, &p, true) < length) {
1613 prot->SendSimpleResp(501, NULL, NULL, (char *) "Error in getting the PROPFIND request body.", 0, false);
1614 return -1;
1615 }
1616
1617 if ((depth > 1) || (depth < 0)) {
1618 prot->SendSimpleResp(501, NULL, NULL, (char *) "Invalid depth value.", 0, false);
1619 return -1;
1620 }
1621
1622
1623 parseBody(p, length);
1624 }
1625
1626
1627 // --------- STAT is always the first step
1628 memset(&xrdreq, 0, sizeof (ClientRequest));
1629 xrdreq.stat.requestid = htons(kXR_stat);
1630 std::string s = resourceplusopaque.c_str();
1631
1632
1633 l = resourceplusopaque.length() + 1;
1634 xrdreq.stat.dlen = htonl(l);
1635
1636 if (!prot->Bridge->Run((char *) &xrdreq, (char *) resourceplusopaque.c_str(), l)) {
1637 prot->SendSimpleResp(501, NULL, NULL, (char *) "Could not run request.", 0, false);
1638 return -1;
1639 }
1640
1641
1642 if (depth == 0) {
1643 // We don't need to be invoked again
1644 return 1;
1645 } else
1646 // We need to be invoked again to complete the request
1647 return 0;
1648
1649
1650
1651 break;
1652 }
1653
1654 default: // Dirlist()
1655 {
1656
1657 // --------- DIRLIST
1658 memset(&xrdreq, 0, sizeof (ClientRequest));
1659 xrdreq.dirlist.requestid = htons(kXR_dirlist);
1660
1661 std::string s = resourceplusopaque.c_str();
1662 xrdreq.dirlist.options[0] = kXR_dstat;
1663 //s += "?xrd.dirstat=1";
1664
1665 l = s.length() + 1;
1666 xrdreq.dirlist.dlen = htonl(l);
1667
1668 if (!prot->Bridge->Run((char *) &xrdreq, (char *) s.c_str(), l)) {
1669 prot->SendSimpleResp(501, NULL, NULL, (char *) "Could not run request.", 0, false);
1670 return -1;
1671 }
1672
1673 // We don't want to be invoked again after this request is finished
1674 return 1;
1675 }
1676 }
1677
1678
1679 break;
1680 }
1682 {
1683
1684 // --------- MKDIR
1685 memset(&xrdreq, 0, sizeof (ClientRequest));
1686 xrdreq.mkdir.requestid = htons(kXR_mkdir);
1687
1688 std::string s = resourceplusopaque.c_str();
1689 xrdreq.mkdir.options[0] = (kXR_char) kXR_mkdirpath;
1690
1691 l = s.length() + 1;
1692 xrdreq.mkdir.dlen = htonl(l);
1693
1694 if (!prot->Bridge->Run((char *) &xrdreq, (char *) s.c_str(), l)) {
1695 prot->SendSimpleResp(501, NULL, NULL, (char *) "Could not run request.", 0, false);
1696 return -1;
1697 }
1698
1699 // We don't want to be invoked again after this request is finished
1700 return 1;
1701 }
1702 case XrdHttpReq::rtMOVE:
1703 {
1704
1705 // --------- MOVE
1706 memset(&xrdreq, 0, sizeof (ClientRequest));
1707 xrdreq.mv.requestid = htons(kXR_mv);
1708
1709 std::string s = resourceplusopaque.c_str();
1710 s += " ";
1711
1712 char buf[256];
1713 char *ppath;
1714 int port = 0;
1715 if (parseURL((char *) destination.c_str(), buf, port, &ppath)) {
1716 prot->SendSimpleResp(501, NULL, NULL, (char *) "Cannot parse destination url.", 0, false);
1717 return -1;
1718 }
1719
1720 char buf2[256];
1721 strcpy(buf2, host.c_str());
1722 char *pos = strchr(buf2, ':');
1723 if (pos) *pos = '\0';
1724
1725 // If we are a redirector we enforce that the host field is equal to
1726 // whatever was written in the destination url
1727 //
1728 // If we are a data server instead we cannot enforce anything, we will
1729 // just ignore the host part of the destination
1730 if ((prot->myRole == kXR_isManager) && strcmp(buf, buf2)) {
1731 prot->SendSimpleResp(501, NULL, NULL, (char *) "Only in-place renaming is supported for MOVE.", 0, false);
1732 return -1;
1733 }
1734
1735
1736
1737
1738 s += ppath;
1739
1740 l = s.length() + 1;
1741 xrdreq.mv.dlen = htonl(l);
1742 xrdreq.mv.arg1len = htons(resourceplusopaque.length());
1743
1744 if (!prot->Bridge->Run((char *) &xrdreq, (char *) s.c_str(), l)) {
1745 prot->SendSimpleResp(501, NULL, NULL, (char *) "Could not run request.", 0, false);
1746 return -1;
1747 }
1748
1749 // We don't want to be invoked again after this request is finished
1750 return 1;
1751
1752 }
1753 default:
1754 {
1755 prot->SendSimpleResp(501, NULL, NULL, (char *) "Request not supported.", 0, false);
1756 return -1;
1757 }
1758
1759 }
1760
1761 return 1;
1762}
#define kXR_isManager
@ kXR_open_wrto
Definition XProtocol.hh:469
@ kXR_delete
Definition XProtocol.hh:453
@ kXR_open_read
Definition XProtocol.hh:456
@ kXR_mkpath
Definition XProtocol.hh:460
@ kXR_new
Definition XProtocol.hh:455
@ kXR_retstat
Definition XProtocol.hh:463
@ kXR_dstat
Definition XProtocol.hh:240
@ kXR_read
Definition XProtocol.hh:125
@ kXR_mkdir
Definition XProtocol.hh:120
@ kXR_dirlist
Definition XProtocol.hh:116
@ kXR_rm
Definition XProtocol.hh:126
@ kXR_write
Definition XProtocol.hh:131
@ kXR_rmdir
Definition XProtocol.hh:127
@ kXR_mv
Definition XProtocol.hh:121
@ kXR_stat
Definition XProtocol.hh:129
@ kXR_close
Definition XProtocol.hh:115
@ kXR_mkdirpath
Definition XProtocol.hh:410
@ kXR_gw
Definition XProtocol.hh:444
@ kXR_ur
Definition XProtocol.hh:440
@ kXR_uw
Definition XProtocol.hh:441
@ kXR_gr
Definition XProtocol.hh:443
@ kXR_or
Definition XProtocol.hh:446
@ kXR_isDir
int kXR_int32
Definition XPtypes.hh:89
unsigned char kXR_char
Definition XPtypes.hh:65
#define DEBUG(x)
int parseURL(char *url, char *host, int &port, char **path)
std::vector< XrdOucIOVec2 > XrdHttpIOList
std::string obfuscateAuth(const std::string &input)
#define TRACE_DEBUG
Definition XrdTrace.hh:36
#define TRACING(x)
Definition XrdTrace.hh:70
#define TRACEI(act, x)
Definition XrdTrace.hh:66
virtual int ProcessReq(XrdHttpExtReq &)=0
int reqstate
State machine to talk to the bridge.
char fhandle[4]
int ReqReadV(const XrdHttpIOList &cl)
Prepare the buffers for sending a readv request.
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.
Definition XrdHttpReq.cc:94
std::vector< readahead_list > ralist
XrdOucString resource
The resource specified by the request, stripped of opaque data.
int ProcessHTTPReq()
XrdOucString resourceplusopaque
The resource specified by the request, including all the opaque data.
std::string host
The host field specified in the req.
XrdHttpChecksumHandler::XrdHttpChecksumRawPtr m_req_cksum
The checksum that was ran for this request.
bool m_appended_hdr2cgistr
void appendOpaque(XrdOucString &s, XrdSecEntity *secent, char *hash, time_t tnow)
XrdOucString m_resource_with_digest
long long filesize
bool readClosing
int erasefromend(int sz=0)
bool endswith(char c)
void append(const int i)
const char * c_str() const

References XrdOucString::append(), appendOpaque(), XrdOucString::c_str(), XrdHttpProtocol::StaticPreloadInfo::data, DEBUG, depth, destination, XrdOucString::endswith(), XrdOucString::erasefromend(), fhandle, fileflags, filesize, fopened, hdr2cgistr, host, keepalive, kXR_close, kXR_delete, kXR_dirlist, kXR_dstat, kXR_gr, kXR_gw, kXR_isDir, kXR_isManager, kXR_mkdir, kXR_mkdirpath, kXR_mkpath, kXR_mv, kXR_new, kXR_open, kXR_open_read, kXR_open_wrto, kXR_or, kXR_read, kXR_retstat, kXR_rm, kXR_rmdir, kXR_stat, kXR_ur, kXR_uw, kXR_write, XrdHttpProtocol::StaticPreloadInfo::len, length, m_appended_hdr2cgistr, m_req_cksum, m_req_digest, m_resource_with_digest, obfuscateAuth(), opaque, parseBody(), parseURL(), ProcessHTTPReq(), XrdHttpExtHandler::ProcessReq(), quote(), ralist, readClosing, readRangeHandler, ReqReadV(), reqstate, request, reset(), resource, resourceplusopaque, rtDELETE, rtGET, rtHEAD, rtMalformed, rtMKCOL, rtMOVE, rtOPTIONS, rtPATCH, rtPROPFIND, rtPUT, rtUnknown, rtUnset, sendcontinue, TRACE, TRACE_DEBUG, TRACEI, TRACING, writtenbytes, and xrdreq.

Referenced by ProcessHTTPReq().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Redir()

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.

Definition at line 533 of file XrdHttpReq.cc.

536 {
537
538
539
540 char buf[512];
541 char hash[512];
542 hash[0] = '\0';
543
544 if (prot->isdesthttps)
545 redirdest = "Location: https://";
546 else
547 redirdest = "Location: http://";
548
549 // port < 0 signals switch to full URL
550 if (port < 0)
551 {
552 if (strncmp(hname, "file://", 7) == 0)
553 {
554 TRACE(REQ, " XrdHttpReq::Redir Switching to file:// ");
555 redirdest = "Location: "; // "file://" already contained in hname
556 }
557 }
558 // Beware, certain Ofs implementations (e.g. EOS) add opaque data directly to the host name
559 // This must be correctly treated here and appended to the opaque info
560 // that we may already have
561 char *pp = strchr((char *)hname, '?');
562 char *vardata = 0;
563 if (pp) {
564 *pp = '\0';
565 redirdest += hname;
566 vardata = pp+1;
567 int varlen = strlen(vardata);
568
569 //Now extract the remaining, vardata points to it
570 while(*vardata == '&' && varlen) {vardata++; varlen--;}
571
572 // Put the question mark back where it was
573 *pp = '?';
574 }
575 else
576 redirdest += hname;
577
578 if (port > 0) {
579 sprintf(buf, ":%d", port);
580 redirdest += buf;
581 }
582
583 redirdest += resource.c_str();
584
585 // Here we put back the opaque info, if any
586 if (vardata) {
587 char *newvardata = quote(vardata);
588 redirdest += "?&";
589 redirdest += newvardata;
590 free(newvardata);
591 }
592
593 // Shall we put also the opaque data of the request? Maybe not
594 //int l;
595 //if (opaque && opaque->Env(l))
596 // redirdest += opaque->Env(l);
597
598
599 time_t timenow = 0;
600 if (!prot->isdesthttps && prot->ishttps) {
601 // If the destination is not https, then we suppose that it
602 // will need this token to fill its authorization info
603 timenow = time(0);
604 calcHashes(hash, this->resource.c_str(), (kXR_int16) request,
605 &prot->SecEntity,
606 timenow,
607 prot->secretkey);
608 }
609
610 if (hash[0]) {
611 appendOpaque(redirdest, &prot->SecEntity, hash, timenow);
612 } else
613 appendOpaque(redirdest, 0, 0, 0);
614
615
616 TRACE(REQ, " XrdHttpReq::Redir Redirecting to " << obfuscateAuth(redirdest.c_str()).c_str());
617
618 if (request != rtGET)
619 prot->SendSimpleResp(307, NULL, (char *) redirdest.c_str(), 0, 0, keepalive);
620 else
621 prot->SendSimpleResp(302, NULL, (char *) redirdest.c_str(), 0, 0, keepalive);
622
623 bool ret_keepalive = keepalive; // reset() clears keepalive
624 reset();
625 return ret_keepalive;
626};
short kXR_int16
Definition XPtypes.hh:66
void calcHashes(char *hash, const char *fn, kXR_int16 request, XrdSecEntity *secent, time_t tim, const char *key)
XrdOucString redirdest

References appendOpaque(), calcHashes(), keepalive, obfuscateAuth(), quote(), redirdest, request, reset(), resource, rtGET, and TRACE.

+ Here is the call graph for this function:

◆ ReqReadV()

int XrdHttpReq::ReqReadV ( const XrdHttpIOList & cl)

Prepare the buffers for sending a readv request.

Definition at line 388 of file XrdHttpReq.cc.

388 {
389
390
391 // Now we build the protocol-ready read ahead list
392 // and also put the correct placeholders inside the cache
393 int n = cl.size();
394 ralist.clear();
395 ralist.reserve(n);
396
397 int j = 0;
398 for (const auto &c: cl) {
399 ralist.emplace_back();
400 auto &ra = ralist.back();
401 memcpy(&ra.fhandle, this->fhandle, 4);
402
403 ra.offset = c.offset;
404 ra.rlen = c.size;
405 j++;
406 }
407
408 if (j > 0) {
409
410 // Prepare a request header
411
412 memset(&xrdreq, 0, sizeof (xrdreq));
413
414 xrdreq.header.requestid = htons(kXR_readv);
415 xrdreq.readv.dlen = htonl(j * sizeof (struct readahead_list));
416
417 clientMarshallReadAheadList(j);
418
419
420 }
421
422 return (j * sizeof (struct readahead_list));
423}
@ kXR_readv
Definition XProtocol.hh:137

References kXR_readv, ralist, and xrdreq.

Referenced by ProcessHTTPReq().

+ Here is the caller graph for this function:

◆ reset()

void XrdHttpReq::reset ( )
virtual

State machine to talk to the bridge

Definition at line 2735 of file XrdHttpReq.cc.

2735 {
2736
2737 TRACE(REQ, " XrdHttpReq request ended.");
2738
2739 //if (xmlbody) xmlFreeDoc(xmlbody);
2740 readRangeHandler.reset();
2741 readClosing = false;
2742 writtenbytes = 0;
2743 etext.clear();
2744 redirdest = "";
2745
2746 // // Here we should deallocate this
2747 // const struct iovec *iovP //!< pointer to data array
2748 // int iovN, //!< array count
2749 // int iovL, //!< byte count
2750 // bool final //!< true -> final result
2751
2752
2753 //xmlbody = 0;
2754 depth = 0;
2757 ralist.clear();
2758 ralist.shrink_to_fit();
2759
2760 request = rtUnset;
2761 resource = "";
2762 allheaders.clear();
2763
2764 // Reset the state of the request's digest request.
2765 m_req_digest.clear();
2766 m_digest_header.clear();
2767 m_req_cksum = nullptr;
2768
2770 m_user_agent = "";
2771
2772 headerok = false;
2773 keepalive = true;
2774 length = 0;
2775 filesize = 0;
2776 depth = 0;
2777 sendcontinue = false;
2778
2779 m_transfer_encoding_chunked = false;
2780 m_current_chunk_size = -1;
2781 m_current_chunk_offset = 0;
2782
2783 m_trailer_headers = false;
2784 m_status_trailer = false;
2785
2787 reqstate = 0;
2788
2789 memset(&xrdreq, 0, sizeof (xrdreq));
2790 memset(&xrdresp, 0, sizeof (xrdresp));
2792
2793 etext.clear();
2794 redirdest = "";
2795
2796 stringresp = "";
2797
2798 host = "";
2799 destination = "";
2800 hdr2cgistr = "";
2801 m_appended_hdr2cgistr = false;
2802
2803 iovP = 0;
2804 iovN = 0;
2805 iovL = 0;
2806
2807
2808 if (opaque) delete(opaque);
2809 opaque = 0;
2810
2811 fopened = false;
2812
2813 final = false;
2814
2815 mScitag = -1;
2816}
@ kXR_noErrorYet
@ kXR_noResponsesYet
Definition XProtocol.hh:908
std::string m_digest_header
The computed digest for the HTTP response header.
std::string stringresp
If we want to give a string as a response, we compose it here.

References allheaders, depth, destination, etext, filesize, fopened, hdr2cgistr, headerok, host, iovL, iovN, iovP, keepalive, kXR_noErrorYet, kXR_noResponsesYet, length, m_appended_hdr2cgistr, m_digest_header, m_req_cksum, m_req_digest, m_resource_with_digest, mScitag, opaque, ralist, readClosing, readRangeHandler, redirdest, reqstate, request, resource, rtUnset, sendcontinue, stringresp, TRACE, writtenbytes, xrderrcode, xrdreq, and xrdresp.

Referenced by ~XrdHttpReq(), Data(), Done(), Error(), ProcessHTTPReq(), and Redir().

+ Here is the caller graph for this function:

◆ userAgent()

const std::string & XrdHttpReq::userAgent ( ) const
inline

Definition at line 210 of file XrdHttpReq.hh.

210{return m_user_agent;}

Member Data Documentation

◆ allheaders

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

Definition at line 241 of file XrdHttpReq.hh.

Referenced by parseLine(), and reset().

◆ depth

int XrdHttpReq::depth

Definition at line 260 of file XrdHttpReq.hh.

Referenced by XrdHttpReq(), parseLine(), ProcessHTTPReq(), and reset().

◆ destination

std::string XrdHttpReq::destination

The destination field specified in the req.

Definition at line 266 of file XrdHttpReq.hh.

Referenced by parseLine(), ProcessHTTPReq(), and reset().

◆ etext

std::string XrdHttpReq::etext

Definition at line 299 of file XrdHttpReq.hh.

Referenced by Error(), and reset().

◆ fhandle

char XrdHttpReq::fhandle[4]

Definition at line 313 of file XrdHttpReq.hh.

Referenced by ProcessHTTPReq().

◆ filectime

long XrdHttpReq::filectime

Definition at line 312 of file XrdHttpReq.hh.

◆ fileflags

long XrdHttpReq::fileflags

Definition at line 310 of file XrdHttpReq.hh.

Referenced by ProcessHTTPReq().

◆ filemodtime

long XrdHttpReq::filemodtime

Definition at line 311 of file XrdHttpReq.hh.

◆ filesize

long long XrdHttpReq::filesize

Definition at line 309 of file XrdHttpReq.hh.

Referenced by ProcessHTTPReq(), and reset().

◆ final

bool XrdHttpReq::final

true -> final result

Definition at line 306 of file XrdHttpReq.hh.

◆ fopened

bool XrdHttpReq::fopened

Definition at line 314 of file XrdHttpReq.hh.

Referenced by XrdHttpReq(), ProcessHTTPReq(), and reset().

◆ hdr2cgistr

std::string XrdHttpReq::hdr2cgistr

Additional opaque info that may come from the hdr2cgi directive.

Definition at line 282 of file XrdHttpReq.hh.

Referenced by addCgi(), appendOpaque(), ProcessHTTPReq(), and reset().

◆ headerok

bool XrdHttpReq::headerok

Tells if we have finished reading the header.

Definition at line 252 of file XrdHttpReq.hh.

Referenced by XrdHttpReq(), and reset().

◆ host

std::string XrdHttpReq::host

The host field specified in the req.

Definition at line 264 of file XrdHttpReq.hh.

Referenced by ProcessHTTPReq(), and reset().

◆ iovL

int XrdHttpReq::iovL

byte count

Definition at line 305 of file XrdHttpReq.hh.

Referenced by Data(), and reset().

◆ iovN

int XrdHttpReq::iovN

array count

Definition at line 304 of file XrdHttpReq.hh.

Referenced by Data(), Done(), and reset().

◆ 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

Definition at line 303 of file XrdHttpReq.hh.

Referenced by Data(), and reset().

◆ keepalive

bool XrdHttpReq::keepalive

Definition at line 258 of file XrdHttpReq.hh.

Referenced by XrdHttpReq(), parseFirstLine(), parseLine(), ProcessHTTPReq(), Redir(), and reset().

◆ length

long long XrdHttpReq::length

◆ m_appended_hdr2cgistr

bool XrdHttpReq::m_appended_hdr2cgistr

Definition at line 283 of file XrdHttpReq.hh.

Referenced by ProcessHTTPReq(), and reset().

◆ m_digest_header

std::string XrdHttpReq::m_digest_header

The computed digest for the HTTP response header.

Definition at line 279 of file XrdHttpReq.hh.

Referenced by reset().

◆ m_req_cksum

XrdHttpChecksumHandler::XrdHttpChecksumRawPtr XrdHttpReq::m_req_cksum = nullptr

The checksum that was ran for this request.

Definition at line 272 of file XrdHttpReq.hh.

Referenced by ProcessHTTPReq(), and reset().

◆ m_req_digest

std::string XrdHttpReq::m_req_digest

The requested digest type.

Definition at line 269 of file XrdHttpReq.hh.

Referenced by parseLine(), ProcessHTTPReq(), and reset().

◆ 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.

Definition at line 277 of file XrdHttpReq.hh.

Referenced by ProcessHTTPReq(), and reset().

◆ mScitag

int XrdHttpReq::mScitag

Definition at line 325 of file XrdHttpReq.hh.

Referenced by XrdHttpExtReq::XrdHttpExtReq(), XrdHttpReq(), and reset().

◆ opaque

XrdOucEnv* XrdHttpReq::opaque

The opaque data, after parsing.

Definition at line 246 of file XrdHttpReq.hh.

Referenced by XrdHttpExtReq::XrdHttpExtReq(), XrdHttpReq(), appendOpaque(), parseLine(), ProcessHTTPReq(), and reset().

◆ ralist

std::vector<readahead_list> XrdHttpReq::ralist

Definition at line 195 of file XrdHttpReq.hh.

Referenced by ProcessHTTPReq(), ReqReadV(), and reset().

◆ readClosing

bool XrdHttpReq::readClosing

Definition at line 256 of file XrdHttpReq.hh.

Referenced by ProcessHTTPReq(), and reset().

◆ readRangeHandler

XrdHttpReadRangeHandler XrdHttpReq::readRangeHandler

Tracking the next ranges of data to read during GET.

Definition at line 255 of file XrdHttpReq.hh.

Referenced by XrdHttpReq(), File(), parseLine(), ProcessHTTPReq(), and reset().

◆ redirdest

XrdOucString XrdHttpReq::redirdest

Definition at line 300 of file XrdHttpReq.hh.

Referenced by Redir(), and reset().

◆ reqstate

int XrdHttpReq::reqstate

State machine to talk to the bridge.

Definition at line 320 of file XrdHttpReq.hh.

Referenced by ProcessHTTPReq(), and reset().

◆ request

ReqType XrdHttpReq::request

The request we got.

Definition at line 236 of file XrdHttpReq.hh.

Referenced by Error(), parseFirstLine(), parseLine(), ProcessHTTPReq(), Redir(), and reset().

◆ requestverb

std::string XrdHttpReq::requestverb

Definition at line 237 of file XrdHttpReq.hh.

Referenced by parseFirstLine().

◆ resource

XrdOucString XrdHttpReq::resource

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

Definition at line 244 of file XrdHttpReq.hh.

Referenced by XrdHttpExtReq::XrdHttpExtReq(), ProcessHTTPReq(), Redir(), and reset().

◆ resourceplusopaque

XrdOucString XrdHttpReq::resourceplusopaque

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

Definition at line 248 of file XrdHttpReq.hh.

Referenced by XrdHttpExtReq::XrdHttpExtReq(), and ProcessHTTPReq().

◆ rwOpDone

unsigned int XrdHttpReq::rwOpDone

To coordinate multipart responses across multiple calls.

Definition at line 291 of file XrdHttpReq.hh.

◆ rwOpPartialDone

unsigned int XrdHttpReq::rwOpPartialDone

Definition at line 291 of file XrdHttpReq.hh.

◆ sendcontinue

bool XrdHttpReq::sendcontinue

Definition at line 261 of file XrdHttpReq.hh.

Referenced by parseLine(), ProcessHTTPReq(), and reset().

◆ stringresp

std::string XrdHttpReq::stringresp

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

Definition at line 317 of file XrdHttpReq.hh.

Referenced by reset().

◆ writtenbytes

long long XrdHttpReq::writtenbytes

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

Definition at line 323 of file XrdHttpReq.hh.

Referenced by XrdHttpReq(), ProcessHTTPReq(), and reset().

◆ xrderrcode

XErrorCode XrdHttpReq::xrderrcode

Definition at line 298 of file XrdHttpReq.hh.

Referenced by Error(), and reset().

◆ xrdreq

ClientRequest XrdHttpReq::xrdreq

The last issued xrd request, often pending.

Definition at line 294 of file XrdHttpReq.hh.

Referenced by Error(), ProcessHTTPReq(), ReqReadV(), and reset().

◆ xrdresp

XResponseType XrdHttpReq::xrdresp

The last response data we got.

Definition at line 297 of file XrdHttpReq.hh.

Referenced by Data(), Done(), Error(), and reset().


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