18 bool TPCHandler::Configure(
const char *configfn,
XrdOucEnv *myEnv)
26 usingEC = getenv(
"XRDCL_EC")? true :
false;
29 std::string authLibParms;
30 int cfgFD =
open(configfn, O_RDONLY, 0);
32 m_log.
Emsg(
"Config", errno,
"open config file", configfn);
36 static const char *cvec[] = {
"*** http tpc plugin config:", 0 };
39 while ((val =
Config.GetMyFirstWord())) {
40 if (!strcmp(
"http.desthttps", val)) {
41 if (!(val =
Config.GetWord())) {
43 m_log.
Emsg(
"Config",
"http.desthttps value not specified");
46 if (!strcmp(
"1", val) || !strcasecmp(
"yes", val) || !strcasecmp(
"true", val)) {
48 }
else if (!strcmp(
"0", val) || !strcasecmp(
"no", val) || !strcasecmp(
"false", val)) {
52 m_log.
Emsg(
"Config",
"https.desthttps value is invalid", val);
55 }
else if (!strcmp(
"tpc.trace", val)) {
56 if (!ConfigureLogger(
Config)) {
60 }
else if (!strcmp(
"tpc.fixed_route", val)) {
61 if (!(val =
Config.GetWord())) {
63 m_log.
Emsg(
"Config",
"tpc.fixed_route value not specified");
66 if (!strcmp(
"1", val) || !strcasecmp(
"yes", val) || !strcasecmp(
"true", val)) {
68 }
else if (!strcmp(
"0", val) || !strcasecmp(
"no", val) || !strcasecmp(
"false", val)) {
72 m_log.
Emsg(
"Config",
"tpc.fixed_route value is invalid", val);
75 }
else if (!strcmp(
"tpc.header2cgi",val)) {
84 if(authHdr != hdr2cgimap.end()) {
85 hdr2cgimap.erase(authHdr);
87 }
else if (!strcmp(
"tpc.timeout", val)) {
88 if (!(val =
Config.GetWord())) {
90 m_log.
Emsg(
"Config",
"tpc.timeout value not specified.");
return false;
92 if (
XrdOuca2x::a2tm(m_log,
"timeout value", val, &m_timeout, 0))
return false;
94 if ((val =
Config.GetWord())) {
95 if (
XrdOuca2x::a2tm(m_log,
"first byte timeout value", val, &m_first_timeout, 0))
return false;
97 m_first_timeout = 2*m_timeout;
107 auto env_cadir = getenv(
"XRDTPC_CADIR");
108 if (env_cadir) m_cadir = env_cadir;
110 const char *cadir =
nullptr, *cafile =
nullptr;
111 if ((cadir = env_cadir ? env_cadir : myEnv->
Get(
"http.cadir"))) {
115 if (!m_ca_file->IsValid()) {
116 m_log.
Emsg(
"Config",
"CAs / CRL generation for libcurl failed.");
121 if ((cafile = myEnv->
Get(
"http.cafile"))) {
125 if (!cadir && !cafile) {
127 m_log.
Emsg(
"Config",
"neither xrd.tls cadir nor certfile value specified; is TLS enabled?");
131 if ((sfs_raw_ptr = myEnv->
GetPtr(
"XrdSfsFileSystem*"))) {
133 m_log.
Emsg(
"Config",
"Using filesystem object from the framework.");
136 m_log.
Emsg(
"Config",
"No filesystem object available to HTTP-TPC subsystem. Internal error.");
142 bool TPCHandler::ConfigureLogger(
XrdOucStream &config_obj)
144 char *val = config_obj.
GetWord();
147 m_log.
Emsg(
"Config",
"tpc.trace requires at least one directive [all | error | warning | info | debug | none]");
154 if (!strcasecmp(val,
"all"))
158 else if (!strcasecmp(val,
"error"))
162 else if (!strcasecmp(val,
"warning"))
166 else if (!strcasecmp(val,
"info"))
170 else if (!strcasecmp(val,
"debug"))
174 else if (!strcasecmp(val,
"none"))
180 m_log.
Emsg(
"Config",
"tpc.trace encountered an unknown directive (valid values: [all | error | warning | info | debug | none]):", val);
A pragmatic implementation of the HTTP/DAV protocol for the Xrd framework.
int open(const char *path, int oflag,...)
static int parseHeader2CGI(XrdOucStream &Config, XrdSysError &err, std::map< std::string, std::string > &header2cgi)
Use this function to parse header2cgi configurations.
void * GetPtr(const char *varname)
char * Get(const char *varname)
char * GetWord(int lowcase=0)
static std::map< std::string, T >::const_iterator caseInsensitiveFind(const std::map< std::string, T > &m, const std::string &lowerCaseSearchKey)
static int a2tm(XrdSysError &, const char *emsg, const char *item, int *val, int minv=-1, int maxv=-1)
int Emsg(const char *esfx, int ecode, const char *text1, const char *text2=0)
void setMsgMask(int mask)