xrootd
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
XrdHttpExtHandler.hh
Go to the documentation of this file.
1 //------------------------------------------------------------------------------
2 // This file is part of XrdHTTP: A pragmatic implementation of the
3 // HTTP/WebDAV protocol for the Xrootd framework
4 //
5 // Copyright (c) 2017 by European Organization for Nuclear Research (CERN)
6 // Author: Fabrizio Furano <furano@cern.ch>
7 // File Date: May 2017
8 //------------------------------------------------------------------------------
9 // XRootD is free software: you can redistribute it and/or modify
10 // it under the terms of the GNU Lesser General Public License as published by
11 // the Free Software Foundation, either version 3 of the License, or
12 // (at your option) any later version.
13 //
14 // XRootD is distributed in the hope that it will be useful,
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 // GNU General Public License for more details.
18 //
19 // You should have received a copy of the GNU Lesser General Public License
20 // along with XRootD. If not, see <http://www.gnu.org/licenses/>.
21 //------------------------------------------------------------------------------
22 
23 
24 
25 
26 
27 
28 
29 
30 
31 
32 
33 #ifndef __XRDHTTPEXTHANDLER_H__
34 #define __XRDHTTPEXTHANDLER_H__
35 
36 #include <map>
37 #include <string>
38 
39 #include "XrdNet/XrdNetPMark.hh"
40 
41 class XrdLink;
42 class XrdSecEntity;
43 class XrdHttpReq;
44 class XrdHttpProtocol;
45 
46 // This class summarizes the content of a request, for consumption by an external plugin
48 private:
50 
51 public:
53 
54  std::string verb, resource;
55  std::map<std::string, std::string> &headers;
56 
58  long long length;
59 
61 
62  int mSciTag;
63 
64  // Get full client identifier
65  void GetClientID(std::string &clid);
66 
67  // A view of the XrdSecEntity associated with the request.
68  const XrdSecEntity &GetSecEntity() const;
69 
71  int BuffgetData(int blen, char **data, bool wait);
72 
74  int SendSimpleResp(int code, const char *desc, const char *header_to_add, const char *body, long long bodylen);
75 
77  // API.
78  int StartChunkedResp(int code, const char *desc, const char *header_to_add);
79 
81  // indicates that this is the last chunk in the response.
82  int ChunkResp(const char *body, long long bodylen);
83 };
84 
85 
89 
90 public:
91 
93  // e.g. applying a prefix matching scheme or whatever
94  virtual bool MatchesPath(const char *verb, const char *path) = 0;
95 
99  virtual int ProcessReq(XrdHttpExtReq &) = 0;
100 
102  virtual int Init(const char *cfgfile) = 0;
103 
104  //------------------------------------------------------------------------------
106  //------------------------------------------------------------------------------
107 
109 
110  //------------------------------------------------------------------------------
112  //------------------------------------------------------------------------------
113 
114  virtual ~XrdHttpExtHandler() {}
115 };
116 
117 /******************************************************************************/
118 /* X r d H t t p G e t E x t H a n d l e r */
119 /******************************************************************************/
120 
121 //------------------------------------------------------------------------------
140 
141 //------------------------------------------------------------------------------
142 
143 class XrdSysError;
144 class XrdOucEnv;
145 
146 #define XrdHttpExtHandlerArgs XrdSysError *eDest, \
147  const char *confg, \
148  const char *parms, \
149  XrdOucEnv *myEnv
150 
152 
153 //------------------------------------------------------------------------------
159 //------------------------------------------------------------------------------
160 
166 #endif
XrdHttpExtHandler * XrdHttpGetExtHandler(XrdHttpExtHandlerArgs)
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 &lt; 0 then it is calculated internally.
virtual int Init(const char *cfgfile)=0
Initializes the external request handler.
const XrdSecEntity & GetSecEntity() const
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. Returns the validity.
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: XrdNetPMark.hh:38
Definition: XrdHttpReq.hh:71
virtual ~XrdHttpExtHandler()
Destructor.
Definition: XrdHttpExtHandler.hh:114
XrdHttpProtocol * prot
Definition: XrdHttpExtHandler.hh:49
std::map< std::string, std::string > & headers
Definition: XrdHttpExtHandler.hh:55
int ChunkResp(const char *body, long long bodylen)
Send a (potentially partial) body in a chunked response; invoking with NULL body. ...
XrdNetPMark * pmark
Definition: XrdHttpExtHandler.hh:60
Definition: XrdSysError.hh:89
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.
std::string clientgroups
Definition: XrdHttpExtHandler.hh:57
XrdHttpExtReq(XrdHttpReq *req, XrdHttpProtocol *pr)
Definition: XrdOucEnv.hh:41
int mSciTag
Definition: XrdHttpExtHandler.hh:62
Definition: XrdHttpExtHandler.hh:88
std::string verb
Definition: XrdHttpExtHandler.hh:54
long long length
Definition: XrdHttpExtHandler.hh:58
std::string clienthost
Definition: XrdHttpExtHandler.hh:57
Definition: XrdHttpProtocol.hh:79
virtual int ProcessReq(XrdHttpExtReq &)=0
std::string resource
Definition: XrdHttpExtHandler.hh:54
void GetClientID(std::string &clid)
#define XrdHttpExtHandlerArgs
Definition: XrdHttpExtHandler.hh:146
Definition: XrdSecEntity.hh:64
Definition: XrdHttpExtHandler.hh:47
std::string clientdn
Definition: XrdHttpExtHandler.hh:57
XrdHttpExtHandler()
Constructor.
Definition: XrdHttpExtHandler.hh:108