XRootD
Loading...
Searching...
No Matches
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#include <cstdint>
39
40#include "XrdNet/XrdNetPMark.hh"
41
42class XrdLink;
43class XrdSecEntity;
44class XrdHttpReq;
45class XrdHttpProtocol;
46
47// This class summarizes the content of a request, for consumption by an external plugin
49private:
50 XrdHttpProtocol *prot;
51
52public:
54
55 std::string verb, resource;
56 std::map<std::string, std::string> &headers;
57
59 long long length;
60
62
63 bool tpcForwardCreds = false;
64
66
68 std::map<std::string,std::string> mReprDigest;
70 std::map<std::string, uint8_t> mWantReprDigest;
71 // Get full client identifier
72 void GetClientID(std::string &clid);
73
74 // A view of the XrdSecEntity associated with the request.
75 const XrdSecEntity &GetSecEntity() const;
76
78 int BuffgetData(int blen, char **data, bool wait);
79
81 int SendSimpleResp(int code, const char *desc, const char *header_to_add, const char *body, long long bodylen);
82
83 // Start response to the client; often followed by data in multiple chunks
84 int StartSimpleResp(int code, const char *desc, const char *header_to_add, long long bodylen, bool keepalive);
85
86 // Send generic data to the client
87 int SendData(const char *body, int bodylen);
88
90 // API.
91 int StartChunkedResp(int code, const char *desc, const char *header_to_add);
92
94 // indicates that this is the last chunk in the response.
95 int ChunkResp(const char *body, long long bodylen);
96};
97
98
102
103public:
104
106 // e.g. applying a prefix matching scheme or whatever
107 virtual bool MatchesPath(const char *verb, const char *path) = 0;
108
112 virtual int ProcessReq(XrdHttpExtReq &) = 0;
113
115 virtual int Init(const char *cfgfile) = 0;
116
117 //------------------------------------------------------------------------------
119 //------------------------------------------------------------------------------
120
122
123 //------------------------------------------------------------------------------
125 //------------------------------------------------------------------------------
126
128};
129
130/******************************************************************************/
131/* X r d H t t p G e t E x t H a n d l e r */
132/******************************************************************************/
133
134//------------------------------------------------------------------------------
153
154//------------------------------------------------------------------------------
155
156class XrdSysError;
157class XrdOucEnv;
158
159#define XrdHttpExtHandlerArgs XrdSysError *eDest, \
160 const char *confg, \
161 const char *parms, \
162 XrdOucEnv *myEnv
163
165
166//------------------------------------------------------------------------------
172//------------------------------------------------------------------------------
173
179#endif
XrdHttpExtHandler * XrdHttpGetExtHandler(XrdHttpExtHandlerArgs)
#define XrdHttpExtHandlerArgs
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()
Constructor.
virtual int ProcessReq(XrdHttpExtReq &)=0
virtual ~XrdHttpExtHandler()
Destructor.
virtual int Init(const char *cfgfile)=0
Initializes the external request handler.
std::string clientdn
int StartSimpleResp(int code, const char *desc, const char *header_to_add, long long bodylen, bool keepalive)
std::string clienthost
int ChunkResp(const char *body, long long bodylen)
Send a (potentially partial) body in a chunked response; invoking with NULL body.
XrdHttpExtReq(XrdHttpReq *req, XrdHttpProtocol *pr)
void GetClientID(std::string &clid)
std::map< std::string, std::string > & headers
std::string clientgroups
std::string resource
std::map< std::string, std::string > mReprDigest
Repr-Digest map where the key is the digest name and the value is the base64 encoded digest value.
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.
int SendData(const char *body, int bodylen)
XrdNetPMark * pmark
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....
std::map< std::string, uint8_t > mWantReprDigest
Want-Repr-Digest map where the key is the digest name and the value is the weighted preference.
const XrdSecEntity & GetSecEntity() const
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.