|
|
|||
File indexing completed on 2026-01-08 10:33:33
0001 //------------------------------------------------------------------------------ 0002 // This file is part of XrdHTTP: A pragmatic implementation of the 0003 // HTTP/WebDAV protocol for the Xrootd framework 0004 // 0005 // Copyright (c) 2017 by European Organization for Nuclear Research (CERN) 0006 // Author: Fabrizio Furano <furano@cern.ch> 0007 // File Date: May 2017 0008 //------------------------------------------------------------------------------ 0009 // XRootD is free software: you can redistribute it and/or modify 0010 // it under the terms of the GNU Lesser General Public License as published by 0011 // the Free Software Foundation, either version 3 of the License, or 0012 // (at your option) any later version. 0013 // 0014 // XRootD is distributed in the hope that it will be useful, 0015 // but WITHOUT ANY WARRANTY; without even the implied warranty of 0016 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0017 // GNU General Public License for more details. 0018 // 0019 // You should have received a copy of the GNU Lesser General Public License 0020 // along with XRootD. If not, see <http://www.gnu.org/licenses/>. 0021 //------------------------------------------------------------------------------ 0022 0023 0024 0025 0026 0027 0028 0029 0030 0031 0032 0033 #ifndef __XRDHTTPEXTHANDLER_H__ 0034 #define __XRDHTTPEXTHANDLER_H__ 0035 0036 #include <map> 0037 #include <string> 0038 0039 #include "XrdNet/XrdNetPMark.hh" 0040 0041 class XrdLink; 0042 class XrdSecEntity; 0043 class XrdHttpReq; 0044 class XrdHttpProtocol; 0045 0046 // This class summarizes the content of a request, for consumption by an external plugin 0047 class XrdHttpExtReq { 0048 private: 0049 XrdHttpProtocol *prot; 0050 0051 public: 0052 XrdHttpExtReq(XrdHttpReq *req, XrdHttpProtocol *pr); 0053 0054 std::string verb, resource; 0055 std::map<std::string, std::string> &headers; 0056 0057 std::string clientdn, clienthost, clientgroups; 0058 long long length; 0059 0060 XrdNetPMark * pmark; 0061 0062 bool tpcForwardCreds = false; 0063 0064 int mSciTag; 0065 0066 // Get full client identifier 0067 void GetClientID(std::string &clid); 0068 0069 // A view of the XrdSecEntity associated with the request. 0070 const XrdSecEntity &GetSecEntity() const; 0071 0072 /// Get a pointer to data read from the client, valid for up to blen bytes from the buffer. Returns the validity 0073 int BuffgetData(int blen, char **data, bool wait); 0074 0075 /// Sends a basic response. If the length is < 0 then it is calculated internally 0076 int SendSimpleResp(int code, const char *desc, const char *header_to_add, const char *body, long long bodylen); 0077 0078 /// Starts a chunked response; body of request is sent over multiple parts using the SendChunkResp 0079 // API. 0080 int StartChunkedResp(int code, const char *desc, const char *header_to_add); 0081 0082 /// Send a (potentially partial) body in a chunked response; invoking with NULL body 0083 // indicates that this is the last chunk in the response. 0084 int ChunkResp(const char *body, long long bodylen); 0085 }; 0086 0087 0088 /// Base class for a plugin that can handle requests for urls that match 0089 /// a certain set of prefixes 0090 class XrdHttpExtHandler { 0091 0092 public: 0093 0094 /// Tells if the incoming path is recognized as one of the paths that have to be processed 0095 // e.g. applying a prefix matching scheme or whatever 0096 virtual bool MatchesPath(const char *verb, const char *path) = 0; 0097 0098 /// Process an HTTP request and send the response using the calling 0099 /// XrdHttpProtocol instance directly 0100 /// Returns 0 if ok, non0 if errors 0101 virtual int ProcessReq(XrdHttpExtReq &) = 0; 0102 0103 /// Initializes the external request handler 0104 virtual int Init(const char *cfgfile) = 0; 0105 0106 //------------------------------------------------------------------------------ 0107 //! Constructor 0108 //------------------------------------------------------------------------------ 0109 0110 XrdHttpExtHandler() {} 0111 0112 //------------------------------------------------------------------------------ 0113 //! Destructor 0114 //------------------------------------------------------------------------------ 0115 0116 virtual ~XrdHttpExtHandler() {} 0117 }; 0118 0119 /******************************************************************************/ 0120 /* X r d H t t p G e t E x t H a n d l e r */ 0121 /******************************************************************************/ 0122 0123 //------------------------------------------------------------------------------ 0124 //! Obtain an instance of the XrdHttpExtHandler object. 0125 //! 0126 //! This extern "C" function is called when a shared library plug-in containing 0127 //! implementation of this class is loaded. It must exist in the shared library 0128 //! and must be thread-safe. 0129 //! 0130 //! @param eDest -> The error object that must be used to print any errors or 0131 //! other messages (see XrdSysError.hh). 0132 //! @param confg -> Name of the configuration file that was used. This pointer 0133 //! may be null though that would be impossible. 0134 //! @param parms -> Argument string specified on the namelib directive. It may 0135 //! be null or point to a null string if no parms exist. 0136 //! @param myEnv -> Environment variables for configuring the external handler; 0137 //! it my be null. 0138 //! 0139 //! @return Success: A pointer to an instance of the XrdHttpSecXtractor object. 0140 //! Failure: A null pointer which causes initialization to fail. 0141 //! 0142 0143 //------------------------------------------------------------------------------ 0144 0145 class XrdSysError; 0146 class XrdOucEnv; 0147 0148 #define XrdHttpExtHandlerArgs XrdSysError *eDest, \ 0149 const char *confg, \ 0150 const char *parms, \ 0151 XrdOucEnv *myEnv 0152 0153 extern "C" XrdHttpExtHandler *XrdHttpGetExtHandler(XrdHttpExtHandlerArgs); 0154 0155 //------------------------------------------------------------------------------ 0156 //! Declare compilation version. 0157 //! 0158 //! Additionally, you *should* declare the xrootd version you used to compile 0159 //! your plug-in. While not currently required, it is highly recommended to 0160 //! avoid execution issues should the class definition change. Declare it as: 0161 //------------------------------------------------------------------------------ 0162 0163 /*! #include "XrdVersion.hh" 0164 * XrdVERSIONINFO(XrdHttpGetExtHandler,<name>); 0165 * 0166 * where <name> is a 1- to 15-character unquoted name identifying your plugin. 0167 */ 0168 #endif
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|