XRootD
XrdClHttpFilesystem.hh
Go to the documentation of this file.
1 /******************************************************************************/
2 /* Copyright (C) 2025, Pelican Project, Morgridge Institute for Research */
3 /* */
4 /* This file is part of the XrdClHttp client plugin for XRootD. */
5 /* */
6 /* XRootD is free software: you can redistribute it and/or modify it under */
7 /* the terms of the GNU Lesser General Public License as published by the */
8 /* Free Software Foundation, either version 3 of the License, or (at your */
9 /* option) any later version. */
10 /* */
11 /* XRootD is distributed in the hope that it will be useful, but WITHOUT */
12 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
13 /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */
14 /* License for more details. */
15 /* */
16 /* The copyright holder's institutional names and contributor's names may not */
17 /* be used to endorse or promote products derived from this software without */
18 /* specific prior written permission of the institution or contributor. */
19 /******************************************************************************/
20 
21 #ifndef XRDCLHTTP_FILESYSTEM_HH
22 #define XRDCLHTTP_FILESYSTEM_HH
23 
26 
27 #include <XrdCl/XrdClFileSystem.hh>
28 #include <XrdCl/XrdClLog.hh>
30 #include <XrdCl/XrdClURL.hh>
31 
32 #include <shared_mutex>
33 #include <string>
34 #include <unordered_map>
35 #include <utility>
36 #include <vector>
37 
38 namespace XrdCl {
39 
40 class Log;
41 
42 }
43 
44 namespace XrdClHttp {
45 
46 class HandlerQueue;
47 
48 class Filesystem final : public XrdCl::FileSystemPlugIn {
49 public:
50  Filesystem(const std::string &, std::shared_ptr<HandlerQueue> queue, XrdCl::Log *log);
51 
52  virtual ~Filesystem() noexcept;
53 
54  XrdCl::XRootDStatus DirList(const std::string &path,
55  XrdCl::DirListFlags::Flags flags,
56  XrdCl::ResponseHandler *handler,
57  time_t timeout) override;
58 
59  virtual bool GetProperty(const std::string &name,
60  std::string &value) const override;
61 
62  virtual XrdCl::XRootDStatus Locate(const std::string &path,
63  XrdCl::OpenFlags::Flags flags,
64  XrdCl::ResponseHandler *handler,
65  time_t timeout) override;
66 
67  virtual XrdCl::XRootDStatus MkDir(const std::string &path,
68  XrdCl::MkDirFlags::Flags flags,
69  XrdCl::Access::Mode mode,
70  XrdCl::ResponseHandler *handler,
71  time_t timeout) override;
72 
73  virtual XrdCl::XRootDStatus Rm(const std::string &path,
74  XrdCl::ResponseHandler *handler,
75  time_t timeout) override;
76 
77  virtual XrdCl::XRootDStatus RmDir(const std::string &path,
78  XrdCl::ResponseHandler *handler,
79  time_t timeout) override;
80 
81  virtual bool SetProperty(const std::string &name,
82  const std::string &value) override;
83 
84  virtual XrdCl::XRootDStatus Stat(const std::string &path,
85  XrdCl::ResponseHandler *handler,
86  time_t timeout) override;
87 
88  virtual XrdCl::XRootDStatus Query(XrdCl::QueryCode::Code queryCode,
89  const XrdCl::Buffer &arg,
90  XrdCl::ResponseHandler *handler,
91  time_t timeout) override;
92 
93 private:
94  // Return a function pointer to the connection callout
95  // Returns nullptr if this file isn't using the callout
96  CreateConnCalloutType GetConnCallout() const;
97 
98  // The "*Response" variant of the callback response objects defined in DirectorCacheResponse.hh
99  // are opt-in; if the caller isn't expecting them, then they will leak memory. This
100  // function determines whether the opt-in is enabled.
101  bool SendResponseInfo() const;
102 
103  // Return the current computed URL to use for HTTP requests, provided the path
104  //
105  // Potentially the user-provided URL plus extra query parameters from the Filesystem properties.
106  std::string GetCurrentURL(const std::string &path) const;
107 
108  // Protects the contents of m_properties
109  mutable std::shared_mutex m_properties_mutex;
110 
111  std::shared_ptr<HandlerQueue> m_queue;
112  std::atomic<XrdClHttp::HeaderCallout *> m_header_callout{};
113  XrdCl::Log *m_logger{nullptr};
114  XrdCl::URL m_url;
115  std::unordered_map<std::string, std::string> m_properties;
116 };
117 
118 }
119 
120 #endif // XRDCLHTTP_FILESYSTEM_HH
int Mode
virtual XrdCl::XRootDStatus Stat(const std::string &path, XrdCl::ResponseHandler *handler, time_t timeout) override
virtual XrdCl::XRootDStatus Rm(const std::string &path, XrdCl::ResponseHandler *handler, time_t timeout) override
virtual XrdCl::XRootDStatus Query(XrdCl::QueryCode::Code queryCode, const XrdCl::Buffer &arg, XrdCl::ResponseHandler *handler, time_t timeout) override
virtual XrdCl::XRootDStatus Locate(const std::string &path, XrdCl::OpenFlags::Flags flags, XrdCl::ResponseHandler *handler, time_t timeout) override
virtual XrdCl::XRootDStatus MkDir(const std::string &path, XrdCl::MkDirFlags::Flags flags, XrdCl::Access::Mode mode, XrdCl::ResponseHandler *handler, time_t timeout) override
virtual bool SetProperty(const std::string &name, const std::string &value) override
XrdCl::XRootDStatus DirList(const std::string &path, XrdCl::DirListFlags::Flags flags, XrdCl::ResponseHandler *handler, time_t timeout) override
virtual XrdCl::XRootDStatus RmDir(const std::string &path, XrdCl::ResponseHandler *handler, time_t timeout) override
virtual ~Filesystem() noexcept
virtual bool GetProperty(const std::string &name, std::string &value) const override
Filesystem(const std::string &, std::shared_ptr< HandlerQueue > queue, XrdCl::Log *log)
An interface for file plug-ins.
Handle diagnostics.
Definition: XrdClLog.hh:101
URL representation.
Definition: XrdClURL.hh:31
XrdSysError Log
Definition: XrdConfig.cc:113
ConnectionCallout *(*)(const std::string &, const ResponseInfo &) CreateConnCalloutType