Loading...
Searching...
No Matches
XrdHttpExtHandler.hh
Go to the documentation of this file.
//------------------------------------------------------------------------------
// This file is part of XrdHTTP: A pragmatic implementation of the
// HTTP/WebDAV protocol for the Xrootd framework
//
// Copyright (c) 2017 by European Organization for Nuclear Research (CERN)
// Author: Fabrizio Furano <furano@cern.ch>
// File Date: May 2017
//------------------------------------------------------------------------------
// XRootD is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// XRootD is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with XRootD. If not, see <http://www.gnu.org/licenses/>.
//------------------------------------------------------------------------------
#ifndef __XRDHTTPEXTHANDLER_H__
#define __XRDHTTPEXTHANDLER_H__
#include <map>
#include <string>
#include "XrdNet/XrdNetPMark.hh"
class XrdLink;
class XrdSecEntity;
class XrdHttpReq;
class XrdHttpProtocol;
// This class summarizes the content of a request, for consumption by an external plugin
class XrdHttpExtReq {
private:
XrdHttpProtocol *prot;
public:
XrdHttpExtReq(XrdHttpReq *req, XrdHttpProtocol *pr);
std::string verb, resource;
std::map<std::string, std::string> &headers;
std::string clientdn, clienthost, clientgroups;
long long length;
XrdNetPMark * pmark;
bool tpcForwardCreds = false;
int mSciTag;
// Get full client identifier
void GetClientID(std::string &clid);
// A view of the XrdSecEntity associated with the request.
const XrdSecEntity &GetSecEntity() const;
int BuffgetData(int blen, char **data, bool wait);
int SendSimpleResp(int code, const char *desc, const char *header_to_add, const char *body, long long bodylen);
// API.
int StartChunkedResp(int code, const char *desc, const char *header_to_add);
// indicates that this is the last chunk in the response.
int ChunkResp(const char *body, long long bodylen);
};
class XrdHttpExtHandler {
public:
// e.g. applying a prefix matching scheme or whatever
virtual bool MatchesPath(const char *verb, const char *path) = 0;
virtual int ProcessReq(XrdHttpExtReq &) = 0;
virtual int Init(const char *cfgfile) = 0;
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
XrdHttpExtHandler() {}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
virtual ~XrdHttpExtHandler() {}
};
/******************************************************************************/
/* X r d H t t p G e t E x t H a n d l e r */
/******************************************************************************/
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
class XrdSysError;
class XrdOucEnv;
#define XrdHttpExtHandlerArgs XrdSysError *eDest, \
const char *confg, \
const char *parms, \
XrdOucEnv *myEnv
extern "C" XrdHttpExtHandler *XrdHttpGetExtHandler(XrdHttpExtHandlerArgs);
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
#endif
XrdHttpGetExtHandler
XrdHttpExtHandler * XrdHttpGetExtHandler(XrdHttpExtHandlerArgs)
XrdHttpExtHandlerArgs
#define XrdHttpExtHandlerArgs
Definition XrdHttpExtHandler.hh:148
XrdNetPMark.hh
XrdHttpExtHandler
Definition XrdHttpExtHandler.hh:90
XrdHttpExtHandler::MatchesPath
virtual bool MatchesPath(const char *verb, const char *path)=0
Tells if the incoming path is recognized as one of the paths that have to be processed.
XrdHttpExtHandler::XrdHttpExtHandler
XrdHttpExtHandler()
Constructor.
Definition XrdHttpExtHandler.hh:110
XrdHttpExtHandler::ProcessReq
virtual int ProcessReq(XrdHttpExtReq &)=0
XrdHttpExtHandler::~XrdHttpExtHandler
virtual ~XrdHttpExtHandler()
Destructor.
Definition XrdHttpExtHandler.hh:116
XrdHttpExtHandler::Init
virtual int Init(const char *cfgfile)=0
Initializes the external request handler.
XrdHttpExtReq
Definition XrdHttpExtHandler.hh:47
XrdHttpExtReq::clientdn
std::string clientdn
Definition XrdHttpExtHandler.hh:57
XrdHttpExtReq::clienthost
std::string clienthost
Definition XrdHttpExtHandler.hh:57
XrdHttpExtReq::ChunkResp
int ChunkResp(const char *body, long long bodylen)
Send a (potentially partial) body in a chunked response; invoking with NULL body.
Definition XrdHttpExtHandler.cc:58
XrdHttpExtReq::XrdHttpExtReq
XrdHttpExtReq(XrdHttpReq *req, XrdHttpProtocol *pr)
Definition XrdHttpExtHandler.cc:86
XrdHttpExtReq::GetClientID
void GetClientID(std::string &clid)
Definition XrdHttpExtHandler.cc:73
XrdHttpExtReq::headers
std::map< std::string, std::string > & headers
Definition XrdHttpExtHandler.hh:55
XrdHttpExtReq::clientgroups
std::string clientgroups
Definition XrdHttpExtHandler.hh:57
XrdHttpExtReq::resource
std::string resource
Definition XrdHttpExtHandler.hh:54
XrdHttpExtReq::mSciTag
int mSciTag
Definition XrdHttpExtHandler.hh:64
XrdHttpExtReq::verb
std::string verb
Definition XrdHttpExtHandler.hh:54
XrdHttpExtReq::StartChunkedResp
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.
Definition XrdHttpExtHandler.cc:51
XrdHttpExtReq::length
long long length
Definition XrdHttpExtHandler.hh:58
XrdHttpExtReq::pmark
XrdNetPMark * pmark
Definition XrdHttpExtHandler.hh:60
XrdHttpExtReq::BuffgetData
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....
Definition XrdHttpExtHandler.cc:65
XrdHttpExtReq::GetSecEntity
const XrdSecEntity & GetSecEntity() const
Definition XrdHttpExtHandler.cc:80
XrdHttpExtReq::tpcForwardCreds
bool tpcForwardCreds
Definition XrdHttpExtHandler.hh:62
XrdHttpExtReq::SendSimpleResp
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.
Definition XrdHttpExtHandler.cc:31
XrdHttpProtocol
Definition XrdHttpProtocol.hh:81
XrdHttpReq
Definition XrdHttpReq.hh:71
XrdLink
Definition XrdLink.hh:52
XrdNetPMark
Definition XrdNetPMark.hh:41
XrdOucEnv
Definition XrdOucEnv.hh:42
XrdSecEntity
Definition XrdSecEntity.hh:65
XrdSysError
Definition XrdSysError.hh:90