31 #ifndef CPL_AWS_INCLUDED_H 32 #define CPL_AWS_INCLUDED_H 42 #include <curl/curl.h> 45 CPLString CPLGetLowerCaseHexSHA256(
const void *pabyData,
size_t nBytes );
52 CPLString CPLAWSGetHeaderVal(
const struct curl_slist* psExistingHeaders,
56 CPLGetAWS_SIGN4_Signature(
const CPLString& osSecretAccessKey,
62 const struct curl_slist* psExistingHeaders,
77 const struct curl_slist* psExistingHeaders,
84 class IVSIS3LikeHandleHelper
89 std::map<CPLString, CPLString> m_oMapQueryParameters{};
91 virtual void RebuildURL() = 0;
92 CPLString GetQueryString(
bool bAddEmptyValueAfterEqual)
const;
95 IVSIS3LikeHandleHelper() =
default;
96 virtual ~IVSIS3LikeHandleHelper() =
default;
98 void ResetQueryParameters();
101 virtual struct curl_slist* GetCurlHeaders(
const CPLString& osVerb,
102 const struct curl_slist* psExistingHeaders,
103 const void *pabyDataContent =
nullptr,
104 size_t nBytesContent = 0)
const = 0;
106 virtual bool AllowAutomaticRedirection() {
return true; }
107 virtual bool CanRestartOnError(
const char*,
const char* ,
108 bool ,
bool* =
nullptr) {
return false;}
110 virtual const CPLString& GetURL()
const = 0;
112 static bool GetBucketAndObjectKey(
const char* pszURI,
113 const char* pszFSPrefix,
118 static CPLString BuildCanonicalizedHeaders(
119 std::map<CPLString, CPLString>& oSortedMapHeaders,
120 const struct curl_slist* psExistingHeaders,
121 const char* pszHeaderPrefix);
126 class VSIS3HandleHelper final:
public IVSIS3LikeHandleHelper
139 bool m_bUseHTTPS =
false;
140 bool m_bUseVirtualHosting =
false;
142 void RebuildURL()
override;
144 static bool GetConfigurationFromEC2(
CPLString& osSecretAccessKey,
148 static bool GetConfigurationFromAWSConfigFiles(
163 VSIS3HandleHelper(
const CPLString& osSecretAccessKey,
171 bool bUseHTTPS,
bool bUseVirtualHosting);
172 ~VSIS3HandleHelper();
174 static VSIS3HandleHelper* BuildFromURI(
const char* pszURI,
175 const char* pszFSPrefix,
181 bool bUseHTTPS,
bool bUseVirtualHosting);
183 struct curl_slist* GetCurlHeaders(
185 const struct curl_slist* psExistingHeaders,
186 const void *pabyDataContent =
nullptr,
187 size_t nBytesContent = 0)
const override;
189 bool AllowAutomaticRedirection()
override {
return false; }
190 bool CanRestartOnError(
const char*,
const char* pszHeaders,
192 bool* pbUpdateMap =
nullptr)
override;
194 const CPLString& GetURL()
const override {
return m_osURL; }
195 const CPLString& GetBucket()
const {
return m_osBucket; }
196 const CPLString& GetObjectKey()
const {
return m_osObjectKey; }
197 const CPLString& GetEndpoint()
const {
return m_osEndpoint; }
198 const CPLString& GetRegion()
const {
return m_osRegion; }
199 const CPLString& GetRequestPayer()
const {
return m_osRequestPayer; }
200 bool GetVirtualHosting()
const {
return m_bUseVirtualHosting; }
201 void SetEndpoint(
const CPLString &osStr);
203 void SetRequestPayer(
const CPLString &osStr);
204 void SetVirtualHosting(
bool b);
208 static void CleanMutex();
209 static void ClearCache();
212 class VSIS3UpdateParams
218 bool m_bUseVirtualHosting =
false;
220 VSIS3UpdateParams() =
default;
222 explicit VSIS3UpdateParams(
const VSIS3HandleHelper* poHelper) :
223 m_osRegion(poHelper->GetRegion()),
224 m_osEndpoint(poHelper->GetEndpoint()),
225 m_osRequestPayer(poHelper->GetRequestPayer()),
226 m_bUseVirtualHosting(poHelper->GetVirtualHosting()) {}
228 void UpdateHandlerHelper(VSIS3HandleHelper* poHelper) {
229 poHelper->SetRegion(m_osRegion);
230 poHelper->SetEndpoint(m_osEndpoint);
231 poHelper->SetRequestPayer(m_osRequestPayer);
232 poHelper->SetVirtualHosting(m_bUseVirtualHosting);
Convenient string class based on std::string.
Definition: cpl_string.h:329
Various convenience functions for working with strings and string lists.
char ** CSLConstList
Type of a constant null-terminated list of nul terminated strings.
Definition: cpl_port.h:1186
#define CPL_DISALLOW_COPY_ASSIGN(ClassName)
Helper to remove the copy and assignment constructors so that the compiler will not generate the defa...
Definition: cpl_port.h:989