00001 //------------------------------------------------------------------------------ 00002 // This file is part of XrdHTTP: A pragmatic implementation of the 00003 // HTTP/WebDAV protocol for the Xrootd framework 00004 // 00005 // Copyright (c) 2017 by European Organization for Nuclear Research (CERN) 00006 // Author: Fabrizio Furano <furano@cern.ch> 00007 // File Date: May 2017 00008 //------------------------------------------------------------------------------ 00009 // XRootD is free software: you can redistribute it and/or modify 00010 // it under the terms of the GNU Lesser General Public License as published by 00011 // the Free Software Foundation, either version 3 of the License, or 00012 // (at your option) any later version. 00013 // 00014 // XRootD is distributed in the hope that it will be useful, 00015 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00017 // GNU General Public License for more details. 00018 // 00019 // You should have received a copy of the GNU Lesser General Public License 00020 // along with XRootD. If not, see <http://www.gnu.org/licenses/>. 00021 //------------------------------------------------------------------------------ 00022 00023 00024 00025 00026 00027 00028 00029 00030 00031 00032 00033 #ifndef __XRDHTTPEXTHANDLER_H__ 00034 #define __XRDHTTPEXTHANDLER_H__ 00035 00036 #include <map> 00037 #include <string> 00038 00039 class XrdLink; 00040 class XrdSecEntity; 00041 class XrdHttpReq; 00042 class XrdHttpProtocol; 00043 00044 // This class summarizes the content of a request, for consumption by an external plugin 00045 class XrdHttpExtReq { 00046 private: 00047 XrdHttpProtocol *prot; 00048 00049 public: 00050 XrdHttpExtReq(XrdHttpReq *req, XrdHttpProtocol *pr); 00051 00052 std::string verb, resource; 00053 std::map<std::string, std::string> &headers; 00054 00055 std::string clientdn, clienthost, clientgroups; 00056 long long length; 00057 00058 // A view of the XrdSecEntity associated with the request. 00059 const XrdSecEntity &GetSecEntity() const; 00060 00062 int BuffgetData(int blen, char **data, bool wait); 00063 00065 int SendSimpleResp(int code, const char *desc, const char *header_to_add, const char *body, long long bodylen); 00066 00068 // API. 00069 int StartChunkedResp(int code, const char *desc, const char *header_to_add); 00070 00072 // indicates that this is the last chunk in the response. 00073 int ChunkResp(const char *body, long long bodylen); 00074 }; 00075 00076 00079 class XrdHttpExtHandler { 00080 00081 public: 00082 00084 // e.g. applying a prefix matching scheme or whatever 00085 virtual bool MatchesPath(const char *verb, const char *path) = 0; 00086 00090 virtual int ProcessReq(XrdHttpExtReq &) = 0; 00091 00093 virtual int Init(const char *cfgfile) = 0; 00094 00095 //------------------------------------------------------------------------------ 00097 //------------------------------------------------------------------------------ 00098 00099 XrdHttpExtHandler() {} 00100 00101 //------------------------------------------------------------------------------ 00103 //------------------------------------------------------------------------------ 00104 00105 virtual ~XrdHttpExtHandler() {} 00106 }; 00107 00108 /******************************************************************************/ 00109 /* X r d H t t p G e t E x t H a n d l e r */ 00110 /******************************************************************************/ 00111 00112 //------------------------------------------------------------------------------ 00131 00132 //------------------------------------------------------------------------------ 00133 00134 class XrdSysError; 00135 class XrdOucEnv; 00136 00137 #define XrdHttpExtHandlerArgs XrdSysError *eDest, \ 00138 const char *confg, \ 00139 const char *parms, \ 00140 XrdOucEnv *myEnv 00141 00142 extern "C" XrdHttpExtHandler *XrdHttpGetExtHandler(XrdHttpExtHandlerArgs); 00143 00144 //------------------------------------------------------------------------------ 00150 //------------------------------------------------------------------------------ 00151 00157 #endif