XRootD
XrdHttpProtocol.cc File Reference
#include "XrdVersion.hh"
#include "Xrd/XrdBuffer.hh"
#include "Xrd/XrdLink.hh"
#include "XProtocol/XProtocol.hh"
#include "XrdOuc/XrdOucStream.hh"
#include "XrdOuc/XrdOucEnv.hh"
#include "XrdOuc/XrdOucGMap.hh"
#include "XrdSys/XrdSysE2T.hh"
#include "XrdSys/XrdSysTimer.hh"
#include "XrdOuc/XrdOucPinLoader.hh"
#include "XrdHttpTrace.hh"
#include "XrdHttpProtocol.hh"
#include <sys/stat.h>
#include "XrdHttpUtils.hh"
#include "XrdHttpSecXtractor.hh"
#include "XrdHttpExtHandler.hh"
#include "XrdTls/XrdTls.hh"
#include "XrdTls/XrdTlsContext.hh"
#include "XrdOuc/XrdOucUtils.hh"
#include "XrdOuc/XrdOucPrivateUtils.hh"
#include <openssl/err.h>
#include <openssl/ssl.h>
#include <vector>
#include <arpa/inet.h>
#include <sstream>
#include <cctype>
#include <fcntl.h>
#include <algorithm>
+ Include dependency graph for XrdHttpProtocol.cc:

Go to the source code of this file.

Namespaces

 XrdHttpProtoInfo
 

Macros

#define HTTPS_ALERT(x, y, z)
 
#define TRACELINK   lp
 
#define TRACELINK   Link
 
#define TRACELINK   Link
 
#define TS_Xeq(x, m)   (!strcmp(x,var)) GoNo = m(Config)
 
#define TS_Xeq3(x, m)   (!strcmp(x,var)) GoNo = m(Config, extHIVec)
 
#define XRHTTP_TK_GRACETIME   600
 

Functions

void * BIO_get_data (BIO *bio)
 
int BIO_get_flags (BIO *bio)
 
int BIO_get_init (BIO *bio)
 
int BIO_get_shutdown (BIO *bio)
 
void BIO_set_data (BIO *bio, void *ptr)
 
void BIO_set_flags (BIO *bio, int flags)
 
void BIO_set_init (BIO *bio, int init)
 
void BIO_set_shutdown (BIO *bio, int shut)
 
static int BIO_XrdLink_create (BIO *bio)
 
static long BIO_XrdLink_ctrl (BIO *bio, int cmd, long num, void *ptr)
 
static int BIO_XrdLink_destroy (BIO *bio)
 
static int BIO_XrdLink_read (BIO *bio, char *data, size_t datal, size_t *read)
 
int BIO_XrdLink_write (BIO *bio, const char *data, size_t datal, size_t *written)
 
static XrdVERSIONINFODEF (compiledVer, XrdHttpProtocolTest, XrdVNUMBER, XrdVERSION)
 

Variables

static const int XrdHttpProtoInfo::hsmAuto = -1
 
static const int XrdHttpProtoInfo::hsmMan = 1
 
static const int XrdHttpProtoInfo::hsmOff = 0
 
static const int XrdHttpProtoInfo::hsmOn = 1
 
int XrdHttpProtoInfo::httpsmode = hsmAuto
 
bool XrdHttpProtoInfo::httpsspec = false
 
std::vector< std::string > XrdHttpProtoInfo::tlsAuthRequestPrefixes
 
int XrdHttpProtoInfo::tlsCache = XrdTlsContext::scOff
 
XrdTlsContext::ClientAuthSetting XrdHttpProtoInfo::tlsClientAuth = XrdTlsContext::ClientAuthSetting::kOn
 
XrdTlsContextXrdHttpProtoInfo::xrdctx = 0
 
bool XrdHttpProtoInfo::xrdctxVer = false
 
const char * XrdHttpSecEntityTident = "http"
 
XrdSysTrace XrdHttpTrace ("http")
 

Macro Definition Documentation

◆ HTTPS_ALERT

#define HTTPS_ALERT (   x,
  y,
 
)
Value:
httpsspec = true;\
if (xrdctx && httpsmode == hsmAuto && (z || xrdctx->x509Verify())) \
eDest.Say("Config http." x " overrides the xrd." y " directive.")
static const int hsmAuto
XrdTlsContext * xrdctx

Definition at line 1058 of file XrdHttpProtocol.cc.

◆ TRACELINK [1/3]

#define TRACELINK   lp

Definition at line 1000 of file XrdHttpProtocol.cc.

◆ TRACELINK [2/3]

#define TRACELINK   Link

Definition at line 1000 of file XrdHttpProtocol.cc.

◆ TRACELINK [3/3]

#define TRACELINK   Link

Definition at line 1000 of file XrdHttpProtocol.cc.

◆ TS_Xeq

#define TS_Xeq (   x,
 
)    (!strcmp(x,var)) GoNo = m(Config)

Definition at line 1054 of file XrdHttpProtocol.cc.

◆ TS_Xeq3

#define TS_Xeq3 (   x,
 
)    (!strcmp(x,var)) GoNo = m(Config, extHIVec)

Definition at line 1056 of file XrdHttpProtocol.cc.

◆ XRHTTP_TK_GRACETIME

#define XRHTTP_TK_GRACETIME   600

Definition at line 58 of file XrdHttpProtocol.cc.

Function Documentation

◆ BIO_get_data()

void* BIO_get_data ( BIO *  bio)

Definition at line 159 of file XrdHttpProtocol.cc.

159  {
160  return bio->ptr;
161 }

Referenced by BIO_XrdLink_ctrl(), BIO_XrdLink_destroy(), BIO_XrdLink_read(), and BIO_XrdLink_write().

+ Here is the caller graph for this function:

◆ BIO_get_flags()

int BIO_get_flags ( BIO *  bio)

Definition at line 166 of file XrdHttpProtocol.cc.

166  {
167  return bio->flags;
168 }

◆ BIO_get_init()

int BIO_get_init ( BIO *  bio)

Definition at line 173 of file XrdHttpProtocol.cc.

173  {
174  return bio->init;
175 }

◆ BIO_get_shutdown()

int BIO_get_shutdown ( BIO *  bio)

Definition at line 182 of file XrdHttpProtocol.cc.

182  {
183  return bio->shutdown;
184 }

Referenced by BIO_XrdLink_ctrl(), and BIO_XrdLink_destroy().

+ Here is the caller graph for this function:

◆ BIO_set_data()

void BIO_set_data ( BIO *  bio,
void *  ptr 
)

Definition at line 162 of file XrdHttpProtocol.cc.

162  {
163  bio->ptr = ptr;
164 }

Referenced by BIO_XrdLink_create().

+ Here is the caller graph for this function:

◆ BIO_set_flags()

void BIO_set_flags ( BIO *  bio,
int  flags 
)

Definition at line 170 of file XrdHttpProtocol.cc.

170  {
171  bio->flags = flags;
172 }

Referenced by BIO_XrdLink_create(), BIO_XrdLink_destroy(), and Tobase64().

+ Here is the caller graph for this function:

◆ BIO_set_init()

void BIO_set_init ( BIO *  bio,
int  init 
)

Definition at line 176 of file XrdHttpProtocol.cc.

176  {
177  bio->init = init;
178 }

Referenced by BIO_XrdLink_create(), and BIO_XrdLink_destroy().

+ Here is the caller graph for this function:

◆ BIO_set_shutdown()

void BIO_set_shutdown ( BIO *  bio,
int  shut 
)

Definition at line 179 of file XrdHttpProtocol.cc.

179  {
180  bio->shutdown = shut;
181 }

Referenced by BIO_XrdLink_ctrl().

+ Here is the caller graph for this function:

◆ BIO_XrdLink_create()

static int BIO_XrdLink_create ( BIO *  bio)
static

Definition at line 406 of file XrdHttpProtocol.cc.

407 {
408 
409 
410  BIO_set_init(bio, 0);
411  //BIO_set_next(bio, 0);
412  BIO_set_data(bio, NULL);
413  BIO_set_flags(bio, 0);
414 
415 #if OPENSSL_VERSION_NUMBER < 0x10100000L
416 
417  bio->num = 0;
418 
419 #endif
420 
421  return 1;
422 }
void BIO_set_init(BIO *bio, int init)
void BIO_set_data(BIO *bio, void *ptr)
void BIO_set_flags(BIO *bio, int flags)

References BIO_set_data(), BIO_set_flags(), and BIO_set_init().

+ Here is the call graph for this function:

◆ BIO_XrdLink_ctrl()

static long BIO_XrdLink_ctrl ( BIO *  bio,
int  cmd,
long  num,
void *  ptr 
)
static

Definition at line 439 of file XrdHttpProtocol.cc.

440 {
441  long ret = 1;
442  switch (cmd) {
443  case BIO_CTRL_GET_CLOSE:
444  ret = BIO_get_shutdown(bio);
445  break;
446  case BIO_CTRL_SET_CLOSE:
447  BIO_set_shutdown(bio, (int)num);
448  break;
449  case BIO_CTRL_DUP:
450  case BIO_CTRL_FLUSH:
451  ret = 1;
452  break;
453  case BIO_C_SET_NBIO:
454  {
455  auto link = static_cast<XrdLink*>(BIO_get_data(bio));
456  if (link) {
457  struct timeval tv;
458  tv.tv_sec = 10;
459  tv.tv_usec = 0;
460  if (num) {
461  tv.tv_sec = 0;
462  tv.tv_usec = 1;
463  }
464  setsockopt(link->FDnum(), SOL_SOCKET, SO_RCVTIMEO, (struct timeval *)&tv, sizeof(struct timeval));
465  setsockopt(link->FDnum(), SOL_SOCKET, SO_SNDTIMEO, (struct timeval *)&tv, sizeof(struct timeval));
466  }
467  ret = 1;
468  break;
469  }
470  default:
471  ret = 0;
472  break;
473  }
474  return ret;
475 }
int BIO_get_shutdown(BIO *bio)
void BIO_set_shutdown(BIO *bio, int shut)
void * BIO_get_data(BIO *bio)

References BIO_get_data(), BIO_get_shutdown(), and BIO_set_shutdown().

+ Here is the call graph for this function:

◆ BIO_XrdLink_destroy()

static int BIO_XrdLink_destroy ( BIO *  bio)
static

Definition at line 425 of file XrdHttpProtocol.cc.

426 {
427  if (bio == NULL) return 0;
428  if (BIO_get_shutdown(bio)) {
429  if (BIO_get_data(bio)) {
430  static_cast<XrdLink*>(BIO_get_data(bio))->Close();
431  }
432  BIO_set_init(bio, 0);
433  BIO_set_flags(bio, 0);
434  }
435  return 1;
436 }
CloseImpl< false > Close(Ctx< File > file, uint16_t timeout=0)
Factory for creating CloseImpl objects.

References BIO_get_data(), BIO_get_shutdown(), BIO_set_flags(), BIO_set_init(), and XrdCl::Close().

+ Here is the call graph for this function:

◆ BIO_XrdLink_read()

static int BIO_XrdLink_read ( BIO *  bio,
char *  data,
size_t  datal,
size_t *  read 
)
static

Definition at line 365 of file XrdHttpProtocol.cc.

366 {
367  if (!data || !bio) {
368  *read = 0;
369  return 0;
370  }
371 
372  errno = 0;
373 
374  XrdLink *lp = static_cast<XrdLink *>(BIO_get_data(bio));
375  int ret = lp->Recv(data, datal);
376  BIO_clear_retry_flags(bio);
377  if (ret <= 0) {
378  *read = 0;
379  if ((errno == EINTR) || (errno == EINPROGRESS) || (errno == EAGAIN) || (errno == EWOULDBLOCK))
380  BIO_set_retry_read(bio);
381  return ret;
382  }
383  *read = ret;
384 }
ssize_t read(int fildes, void *buf, size_t nbyte)

References BIO_get_data(), read(), and XrdLink::Recv().

+ Here is the call graph for this function:

◆ BIO_XrdLink_write()

int BIO_XrdLink_write ( BIO *  bio,
const char *  data,
size_t  datal,
size_t *  written 
)

Definition at line 322 of file XrdHttpProtocol.cc.

323 {
324  if (!data || !bio) {
325  *written = 0;
326  return 0;
327  }
328 
329  XrdLink *lp=static_cast<XrdLink *>(BIO_get_data(bio));
330 
331  errno = 0;
332  int ret = lp->Send(data, datal);
333  BIO_clear_retry_flags(bio);
334  if (ret <= 0) {
335  *written = 0;
336  if ((errno == EINTR) || (errno == EINPROGRESS) || (errno == EAGAIN) || (errno == EWOULDBLOCK))
337  BIO_set_retry_write(bio);
338  return ret;
339  }
340  *written = ret;
341  return 1;
342 }

References BIO_get_data(), and XrdLink::Send().

+ Here is the call graph for this function:

◆ XrdVERSIONINFODEF()

static XrdVERSIONINFODEF ( compiledVer  ,
XrdHttpProtocolTest  ,
XrdVNUMBER  ,
XrdVERSION   
)
static

Variable Documentation

◆ XrdHttpSecEntityTident

const char* XrdHttpSecEntityTident = "http"

Definition at line 66 of file XrdHttpProtocol.cc.

◆ XrdHttpTrace

XrdSysTrace XrdHttpTrace("http") ( "http"  )