XRootD
XrdClHttpResponses.hh
Go to the documentation of this file.
1 /***************************************************************
2  *
3  * Copyright (C) 2025, Morgridge Institute for Research
4  *
5  ***************************************************************/
6 
7 // This file contains class definitions for the responses created by XrdClHttp.
8 // It is a public header, meant to be used by libraries that rely on Curl / HTTP
9 // -specific information such as header or trailers from the responses.
10 
11 #include "XrdClHttpResponseInfo.hh"
12 
14 
15 #include <memory>
16 #include <string>
17 #include <unordered_map>
18 #include <vector>
19 
20 namespace XrdClHttp {
21 
22 // If this property name is set on the XrdCl::FileSystem object to "true",
23 // then XrdClHttp will use the classes defined in this header as response
24 // objects.
25 //
26 // The XrdCl responses do not have a virtual table so, when deleted through
27 // the base pointer, the response info object will leak. The owner of the
28 // FileSystem object is responsible for guaranteeing that `GetResponseInfo`
29 // is called and the allocated memory is released.
30 #define ResponseInfoProperty "XrdClResponseInfo"
31 
32 // Response holding not only the directory listing but the
33 // cumulative response headers from each HTTP request that
34 // contributed to the listing.
36 public:
37  std::unique_ptr<ResponseInfo> GetResponseInfo() {return std::move(m_response_info);}
38  void SetResponseInfo(std::unique_ptr<ResponseInfo> info) {m_response_info = std::move(info);}
39 
40 private:
41  std::unique_ptr<ResponseInfo> m_response_info;
42 };
43 
44 // Response holding not only the stat info but the
45 // cumulative response headers from each HTTP request that
46 // contributed to the listing.
47 class StatResponse : public XrdCl::StatInfo {
48 public:
49  StatResponse(const std::string &id, uint64_t size, uint32_t flags, uint64_t modTime)
50  : XrdCl::StatInfo(id, size, flags, modTime) {}
51 
52  std::unique_ptr<ResponseInfo> GetResponseInfo() {return std::move(m_response_info);}
53  void SetResponseInfo(std::unique_ptr<ResponseInfo> info) {m_response_info = std::move(info);}
54 
55 private:
56  std::unique_ptr<ResponseInfo> m_response_info;
57 };
58 
59 // Response holding not only the query response but any cumulative
60 // response headers from each HTTP request that contributed to the operation
61 //
62 // Note: XrdCl::Buffer has a virtual table so managing response is simpler; no need
63 // to explicitly cast back and forth
64 class QueryResponse : public XrdCl::Buffer {
65 public:
66  virtual ~QueryResponse() {}
67 
68  std::unique_ptr<ResponseInfo> GetResponseInfo() {return std::move(m_response_info);}
69  void SetResponseInfo(std::unique_ptr<ResponseInfo> info) {m_response_info = std::move(info);}
70 private:
71  std::unique_ptr<ResponseInfo> m_response_info;
72 };
73 
75 public:
78  virtual ~OpenResponseInfo() {}
79 
80  std::unique_ptr<ResponseInfo> GetResponseInfo() {return std::move(m_response_info);}
81  void SetResponseInfo(std::unique_ptr<ResponseInfo> info) {m_response_info = std::move(info);}
82 private:
83  std::unique_ptr<ResponseInfo> m_response_info;
84 };
85 
87 public:
88  virtual ~DeleteResponseInfo() {}
89 
90  std::unique_ptr<ResponseInfo> GetResponseInfo() {return std::move(m_response_info);}
91  void SetResponseInfo(std::unique_ptr<ResponseInfo> info) {m_response_info = std::move(info);}
92 private:
93  std::unique_ptr<ResponseInfo> m_response_info;
94 };
95 
97 public:
98  virtual ~MkdirResponseInfo() {}
99 
100  std::unique_ptr<ResponseInfo> GetResponseInfo() {return std::move(m_response_info);}
101  void SetResponseInfo(std::unique_ptr<ResponseInfo> info) {m_response_info = std::move(info);}
102 private:
103  std::unique_ptr<ResponseInfo> m_response_info;
104 };
105 
107 public:
108  ReadResponseInfo(uint64_t off = 0, uint32_t len = 0, void *buff = 0)
109  : XrdCl::ChunkInfo(off, len, buff) {}
110 
111  virtual ~ReadResponseInfo() {}
112 
113  std::unique_ptr<ResponseInfo> GetResponseInfo() {return std::move(m_response_info);}
114  void SetResponseInfo(std::unique_ptr<ResponseInfo> info) {m_response_info = std::move(info);}
115 private:
116  std::unique_ptr<ResponseInfo> m_response_info;
117 };
118 
119 } // namespace XrdClHttp
void SetResponseInfo(std::unique_ptr< ResponseInfo > info)
std::unique_ptr< ResponseInfo > GetResponseInfo()
std::unique_ptr< ResponseInfo > GetResponseInfo()
void SetResponseInfo(std::unique_ptr< ResponseInfo > info)
std::unique_ptr< ResponseInfo > GetResponseInfo()
void SetResponseInfo(std::unique_ptr< ResponseInfo > info)
std::unique_ptr< ResponseInfo > GetResponseInfo()
void SetResponseInfo(std::unique_ptr< ResponseInfo > info)
OpenResponseInfo(OpenResponseInfo &&)=default
std::unique_ptr< ResponseInfo > GetResponseInfo()
void SetResponseInfo(std::unique_ptr< ResponseInfo > info)
void SetResponseInfo(std::unique_ptr< ResponseInfo > info)
std::unique_ptr< ResponseInfo > GetResponseInfo()
ReadResponseInfo(uint64_t off=0, uint32_t len=0, void *buff=0)
std::unique_ptr< ResponseInfo > GetResponseInfo()
void SetResponseInfo(std::unique_ptr< ResponseInfo > info)
StatResponse(const std::string &id, uint64_t size, uint32_t flags, uint64_t modTime)
Binary blob representation.
Definition: XrdClBuffer.hh:34
Object stat info.
Describe a data chunk for vector read.
ChunkInfo(uint64_t off=0, uint32_t len=0, void *buff=0)
Constructor.