13#ifndef CPL_VSIL_CURL_CLASS_H_INCLUDED
14#define CPL_VSIL_CURL_CLASS_H_INCLUDED
24#include "cpl_vsil_curl_priv.h"
25#include "cpl_mem_cache.h"
26#include "cpl_multiproc.h"
28#include "cpl_curl_priv.h"
32#include <condition_variable>
48#define HAVE_CURLINFO_REDIRECT_URL
50void VSICurlStreamingClearCache(
void);
52struct curl_slist *VSICurlSetOptions(CURL *hCurlHandle,
const char *pszURL,
53 const char *
const *papszOptions);
55struct curl_slist *VSICurlSetContentTypeFromExt(
struct curl_slist *polist,
58struct curl_slist *VSICurlSetCreationHeadersFromOptions(
59 struct curl_slist *headers,
CSLConstList papszOptions,
const char *pszPath);
74 unsigned int nGenerationAuthParameters = 0;
75 ExistStatus eExists = EXIST_UNKNOWN;
79 time_t nExpireTimestampLocal = 0;
80 std::string osRedirectURL{};
81 bool bHasComputedFileSize =
false;
82 bool bIsDirectory =
false;
83 bool bIsAzureFolder =
false;
85 bool bS3LikeRedirect =
false;
91 bool bGotFileList =
false;
92 unsigned int nGenerationAuthParameters = 0;
98 char *pBuffer =
nullptr;
100 bool bIsHTTP =
false;
101 bool bMultiRange =
false;
105 int nFirstHTTPCode = 0;
107 bool bFoundContentRange =
false;
109 bool bInterruptDownload =
false;
110 bool bDetectRangeDownloadingError =
false;
114 VSICurlReadCbkFunc pfnReadCbk =
nullptr;
115 void *pReadCbkUserData =
nullptr;
116 bool bInterrupted =
false;
121 const GByte *pabyData =
nullptr;
123 size_t nTotalSize = 0;
125 static size_t ReadCallBackBuffer(
char *buffer,
size_t size,
size_t nitems,
128 PutData *poThis =
static_cast<PutData *
>(instream);
129 const size_t nSizeMax = size * nitems;
130 const size_t nSizeToWrite =
131 std::min(nSizeMax, poThis->nTotalSize - poThis->nOff);
132 memcpy(buffer, poThis->pabyData + poThis->nOff, nSizeToWrite);
133 poThis->nOff += nSizeToWrite;
144class VSICurlFilesystemHandlerBase :
public VSIFilesystemHandler
148 struct FilenameOffsetPair
150 std::string filename_;
153 FilenameOffsetPair(
const std::string &filename,
vsi_l_offset offset)
154 : filename_(filename), offset_(offset)
158 bool operator==(
const FilenameOffsetPair &other)
const
160 return filename_ == other.filename_ && offset_ == other.offset_;
164 struct FilenameOffsetPairHasher
166 std::size_t operator()(
const FilenameOffsetPair &k)
const
168 return std::hash<std::string>()(k.filename_) ^
169 std::hash<vsi_l_offset>()(k.offset_);
173 using RegionCacheType = lru11::Cache<
174 FilenameOffsetPair, std::shared_ptr<std::string>, lru11::NullLock,
177 typename std::list<lru11::KeyValuePair<
178 FilenameOffsetPair, std::shared_ptr<std::string>>>::iterator,
179 FilenameOffsetPairHasher>>;
181 std::unique_ptr<RegionCacheType>
182 m_poRegionCacheDoNotUseDirectly{};
184 RegionCacheType *GetRegionCache();
191 lru11::Cache<std::string, bool> oCacheFileProp;
193 int nCachedFilesInDirList = 0;
194 lru11::Cache<std::string, CachedDirList> oCacheDirList;
196 char **ParseHTMLFileList(
const char *pszFilename,
int nMaxFiles,
197 char *pszData,
bool *pbGotFileList);
202 struct RegionInDownload
205 std::condition_variable oCond{};
206 bool bDownloadInProgress =
false;
208 std::string osData{};
211 std::mutex m_oMutex{};
212 std::map<std::string, std::unique_ptr<RegionInDownload>>
213 m_oMapRegionInDownload{};
216 CPLMutex *hMutex =
nullptr;
218 virtual VSICurlHandle *CreateFileHandle(
const char *pszFilename);
219 virtual char **GetFileList(
const char *pszFilename,
int nMaxFiles,
220 bool *pbGotFileList);
222 void RegisterEmptyDir(
const std::string &osDirname);
225 AnalyseS3FileList(
const std::string &osBaseURL,
const char *pszXML,
227 const std::set<std::string> &oSetIgnoredStorageClasses,
230 void AnalyseSwiftFileList(
const std::string &osBaseURL,
231 const std::string &osPrefix,
const char *pszJson,
233 int nMaxFiles,
bool &bIsTruncated,
234 std::string &osNextMarker);
236 static const char *GetOptionsStatic();
238 VSICurlFilesystemHandlerBase();
241 ~VSICurlFilesystemHandlerBase()
override;
243 static bool IsAllowedFilename(
const char *pszFilename);
245 VSIVirtualHandleUniquePtr Open(
const char *pszFilename,
246 const char *pszAccess,
bool bSetError,
249 int Stat(
const char *pszFilename,
VSIStatBufL *pStatBuf,
250 int nFlags)
override;
251 char **ReadDirEx(
const char *pszDirname,
int nMaxFiles)
override;
252 char **SiblingFiles(
const char *pszFilename)
override;
254 int HasOptimizedReadMultiRange(
const char * )
override
259 const char *GetActualURL(
const char *pszFilename)
override;
261 const char *GetOptions()
override;
263 char **GetFileMetadata(
const char *pszFilename,
const char *pszDomain,
266 char **ReadDirInternal(
const char *pszDirname,
int nMaxFiles,
267 bool *pbGotFileList);
268 void InvalidateDirContent(
const std::string &osDirname);
270 virtual const char *GetDebugKey()
const = 0;
272 virtual std::string GetFSPrefix()
const = 0;
273 virtual bool AllowCachedDataFor(
const char *pszFilename);
275 bool IsLocal(
const char * )
const override
281 SupportsSequentialWrite(
const char * ,
287 virtual bool SupportsRandomWrite(
const char * ,
293 std::shared_ptr<std::string> GetRegion(
const char *pszURL,
296 void AddRegion(
const char *pszURL,
vsi_l_offset nFileOffsetStart,
297 size_t nSize,
const char *pData);
299 std::pair<bool, std::string>
300 NotifyStartDownloadRegion(
const std::string &osURL,
302 void NotifyStopDownloadRegion(
const std::string &osURL,
304 const std::string &osData);
306 bool GetCachedFileProp(
const char *pszURL, FileProp &oFileProp);
307 void SetCachedFileProp(
const char *pszURL, FileProp &oFileProp);
308 void InvalidateCachedData(
const char *pszURL);
310 CURLM *GetCurlMultiHandleFor(
const std::string &osURL);
312 virtual void ClearCache();
313 virtual void PartialClearCache(
const char *pszFilename);
315 bool GetCachedDirList(
const char *pszURL, CachedDirList &oCachedDirList);
316 void SetCachedDirList(
const char *pszURL, CachedDirList &oCachedDirList);
317 bool ExistsInCacheDirList(
const std::string &osDirname,
bool *pbIsDir);
319 virtual std::string GetURLFromFilename(
const std::string &osFilename)
const;
322 GetStreamingFilename(
const std::string &osFilename)
const override = 0;
324 static std::set<std::string> GetS3IgnoredStorageClasses();
327class VSICurlFilesystemHandler final :
public VSICurlFilesystemHandlerBase
332 VSICurlFilesystemHandler() =
default;
334 const char *GetDebugKey()
const override
339 std::string GetFSPrefix()
const override
345 GetStreamingFilename(
const std::string &osFilename)
const override;
348 GetHintForPotentiallyRecognizedPath(
const std::string &osPath)
override;
360 VSICurlFilesystemHandlerBase *poFS =
nullptr;
362 bool m_bCached =
true;
364 mutable FileProp oFileProp{};
366 mutable std::mutex m_oMutex{};
367 std::string m_osFilename{};
368 char *m_pszURL =
nullptr;
369 mutable std::string m_osQueryString{};
372 CPLHTTPRetryParameters
376 int nBlocksToDownload = 1;
378 bool bStopOnInterruptUntilUninstall =
false;
379 bool bInterrupted =
false;
380 VSICurlReadCbkFunc pfnReadCbk =
nullptr;
381 void *pReadCbkUserData =
nullptr;
385 void DownloadRegionPostProcess(
const vsi_l_offset startOffset,
386 const int nBlocks,
const char *pBuffer,
395 virtual std::string DownloadRegion(
vsi_l_offset startOffset,
int nBlocks);
397 bool m_bUseHead =
false;
398 bool m_bUseRedirectURLIfNoQueryStringParams =
false;
400 mutable std::atomic<bool> m_bInterrupt =
false;
404 mutable bool m_bPlanetaryComputerURLSigning =
false;
405 mutable std::string m_osPlanetaryComputerCollection{};
406 void ManagePlanetaryComputerSigning()
const;
408 void UpdateQueryString()
const;
410 int ReadMultiRangeSingleGet(
int nRanges,
void **ppData,
412 const size_t *panSizes);
413 std::string GetRedirectURLIfValid(
bool &bHasExpired,
416 void UpdateRedirectInfo(CURL *hCurlHandle,
417 const WriteFuncStruct &sWriteFuncHeaderData);
420 struct AdviseReadRange
423 bool bToRetry =
true;
424 double dfSleepDelay = 0.0;
426 std::condition_variable oCV{};
429 std::vector<GByte> abyData{};
430 CPLHTTPRetryContext retryContext;
432 explicit AdviseReadRange(
const CPLHTTPRetryParameters &oRetryParameters)
433 : retryContext(oRetryParameters)
437 AdviseReadRange(
const AdviseReadRange &) =
delete;
438 AdviseReadRange &operator=(
const AdviseReadRange &) =
delete;
439 AdviseReadRange(AdviseReadRange &&) =
delete;
440 AdviseReadRange &operator=(AdviseReadRange &&) =
delete;
443 std::vector<std::unique_ptr<AdviseReadRange>> m_aoAdviseReadRanges{};
444 std::thread m_oThreadAdviseRead{};
445 CURLM *m_hCurlMultiHandleForAdviseRead =
nullptr;
448 virtual struct curl_slist *GetCurlHeaders(
const std::string & ,
449 struct curl_slist *psHeaders)
454 virtual bool AllowAutomaticRedirection()
459 virtual bool CanRestartOnError(
const char *,
const char *,
bool)
464 virtual bool UseLimitRangeGetInsteadOfHead()
469 virtual bool IsDirectoryFromExists(
const char * ,
475 virtual void ProcessGetFileSizeResult(
const char * )
479 void SetURL(
const char *pszURL);
481 virtual bool Authenticate(
const char * )
487 VSICurlHandle(VSICurlFilesystemHandlerBase *poFS,
const char *pszFilename,
488 const char *pszURLIn =
nullptr);
489 ~VSICurlHandle()
override;
493 size_t Read(
void *pBuffer,
size_t nBytes)
override;
494 int ReadMultiRange(
int nRanges,
void **ppData,
496 const size_t *panSizes)
override;
497 size_t Write(
const void *pBuffer,
size_t nBytes)
override;
498 void ClearErr()
override;
500 int Error()
override;
501 int Flush()
override;
502 int Close()
override;
504 void Interrupt()
override
509 bool HasPRead()
const override
514 size_t PRead(
void *pBuffer,
size_t nSize,
517 void AdviseRead(
int nRanges,
const vsi_l_offset *panOffsets,
518 const size_t *panSizes)
override;
520 size_t GetAdviseReadTotalBytesLimit()
const override;
522 bool IsKnownFileSize()
const
524 return oFileProp.bHasComputedFileSize;
527 vsi_l_offset GetFileSizeOrHeaders(
bool bSetError,
bool bGetHeaders);
531 return GetFileSizeOrHeaders(bSetError,
false);
534 bool Exists(
bool bSetError);
536 bool IsDirectory()
const
538 return oFileProp.bIsDirectory;
543 return oFileProp.nMode;
546 time_t GetMTime()
const
548 return oFileProp.mTime;
556 int InstallReadCbk(VSICurlReadCbkFunc pfnReadCbk,
void *pfnUserData,
557 int bStopOnInterruptUntilUninstall);
558 int UninstallReadCbk();
560 const char *GetURL()
const
566 void SetCache(
bool bCache)
576class VSICurlFilesystemHandlerBaseWritable
577 :
public VSICurlFilesystemHandlerBase
582 VSICurlFilesystemHandlerBaseWritable() =
default;
584 virtual VSIVirtualHandleUniquePtr
585 CreateWriteHandle(
const char *pszFilename,
CSLConstList papszOptions) = 0;
588 VSIVirtualHandleUniquePtr Open(
const char *pszFilename,
589 const char *pszAccess,
bool bSetError,
592 bool SupportsSequentialWrite(
const char * ,
598 bool SupportsRandomWrite(
const char * ,
606class IVSIS3LikeFSHandler
607 :
public VSICurlFilesystemHandlerBaseWritable
611 virtual int MkdirInternal(
const char *pszDirname,
long nMode,
615 char **GetFileList(
const char *pszFilename,
int nMaxFiles,
616 bool *pbGotFileList)
override;
618 virtual IVSIS3LikeHandleHelper *CreateHandleHelper(
const char *pszURI,
619 bool bAllowNoObject) = 0;
621 virtual int CopyObject(
const char *oldpath,
const char *newpath,
624 int RmdirRecursiveInternal(
const char *pszDirname,
int nBatchSize);
627 IsAllowedHeaderForObjectCreation(
const char * )
632 IVSIS3LikeFSHandler() =
default;
635 int Unlink(
const char *pszFilename)
override;
636 int Mkdir(
const char *pszDirname,
long nMode)
override;
637 int Rmdir(
const char *pszDirname)
override;
638 int Stat(
const char *pszFilename,
VSIStatBufL *pStatBuf,
639 int nFlags)
override;
640 int Rename(
const char *oldpath,
const char *newpath, GDALProgressFunc,
643 virtual int CopyFile(
const char *pszSource,
const char *pszTarget,
645 const char *
const *papszOptions,
646 GDALProgressFunc pProgressFunc,
647 void *pProgressData)
override;
649 virtual int DeleteObject(
const char *pszFilename);
651 virtual int *DeleteObjectBatch(
CSLConstList papszFilesOrDirs);
653 bool Sync(
const char *pszSource,
const char *pszTarget,
654 const char *
const *papszOptions, GDALProgressFunc pProgressFunc,
655 void *pProgressData,
char ***ppapszOutputs)
override;
657 VSIDIR *OpenDir(
const char *pszPath,
int nRecurseDepth,
658 const char *
const *papszOptions)
override;
665class IVSIS3LikeFSHandlerWithMultipartUpload
666 :
public IVSIS3LikeFSHandler
671 IVSIS3LikeFSHandlerWithMultipartUpload() =
default;
674 virtual bool SupportsNonSequentialMultipartUpload()
const
679 virtual bool SupportsParallelMultipartUpload()
const
684 virtual bool SupportsMultipartAbort()
const = 0;
686 size_t GetUploadChunkSizeInBytes(
const char *pszFilename,
687 const char *pszSpecifiedValInBytes);
689 virtual int CopyFileRestartable(
const char *pszSource,
690 const char *pszTarget,
691 const char *pszInputPayload,
692 char **ppszOutputPayload,
694 GDALProgressFunc pProgressFunc,
695 void *pProgressData)
override;
701 virtual int GetMaximumPartCount()
710 virtual int GetMinimumPartSizeInMiB()
719 virtual int GetMaximumPartSizeInMiB()
731 virtual int GetDefaultPartSizeInMiB()
737 InitiateMultipartUpload(
const std::string &osFilename,
738 IVSIS3LikeHandleHelper *poS3HandleHelper,
739 const CPLHTTPRetryParameters &oRetryParameters,
743 UploadPart(
const std::string &osFilename,
int nPartNumber,
745 const void *pabyBuffer,
size_t nBufferSize,
746 IVSIS3LikeHandleHelper *poS3HandleHelper,
747 const CPLHTTPRetryParameters &oRetryParameters,
750 virtual bool CompleteMultipart(
751 const std::string &osFilename,
const std::string &osUploadID,
752 const std::vector<std::string> &aosEtags,
vsi_l_offset nTotalSize,
753 IVSIS3LikeHandleHelper *poS3HandleHelper,
754 const CPLHTTPRetryParameters &oRetryParameters);
756 virtual bool AbortMultipart(
const std::string &osFilename,
757 const std::string &osUploadID,
758 IVSIS3LikeHandleHelper *poS3HandleHelper,
759 const CPLHTTPRetryParameters &oRetryParameters);
761 bool AbortPendingUploads(
const char *pszFilename)
override;
763 bool MultipartUploadGetCapabilities(
int *pbNonSequentialUploadSupported,
764 int *pbParallelUploadSupported,
765 int *pbAbortSupported,
766 size_t *pnMinPartSize,
767 size_t *pnMaxPartSize,
768 int *pnMaxPartCount)
override;
770 char *MultipartUploadStart(
const char *pszFilename,
773 char *MultipartUploadAddPart(
const char *pszFilename,
774 const char *pszUploadId,
int nPartNumber,
779 bool MultipartUploadEnd(
const char *pszFilename,
const char *pszUploadId,
780 size_t nPartIdsCount,
781 const char *
const *apszPartIds,
785 bool MultipartUploadAbort(
const char *pszFilename,
const char *pszUploadId,
793class IVSIS3LikeHandle :
public VSICurlHandle
798 bool UseLimitRangeGetInsteadOfHead()
override
803 bool IsDirectoryFromExists(
const char *pszVerb,
int response_code)
override
806 return response_code == 416 &&
EQUAL(pszVerb,
"GET") &&
807 std::string(m_pszURL).back() ==
'/';
810 void ProcessGetFileSizeResult(
const char *pszContent)
override
812 oFileProp.bIsDirectory =
813 strstr(pszContent,
"ListBucketResult") !=
nullptr;
817 IVSIS3LikeHandle(VSICurlFilesystemHandlerBase *poFSIn,
818 const char *pszFilename,
const char *pszURLIn)
819 : VSICurlHandle(poFSIn, pszFilename, pszURLIn)
823 ~IVSIS3LikeHandle()
override;
834 IVSIS3LikeFSHandlerWithMultipartUpload *m_poFS =
nullptr;
835 std::string m_osFilename{};
836 IVSIS3LikeHandleHelper *m_poS3HandleHelper =
nullptr;
839 CPLHTTPRetryParameters m_oRetryParameters;
842 size_t m_nBufferOff = 0;
843 size_t m_nBufferSize = 0;
844 bool m_bClosed =
false;
845 GByte *m_pabyBuffer =
nullptr;
846 std::string m_osUploadID{};
847 int m_nPartNumber = 0;
848 std::vector<std::string> m_aosEtags{};
849 bool m_bError =
false;
851 WriteFuncStruct m_sWriteFuncHeaderData{};
854 bool DoSinglePartPUT();
856 void InvalidateParentDirectory();
859 VSIMultipartWriteHandle(IVSIS3LikeFSHandlerWithMultipartUpload *poFS,
860 const char *pszFilename,
861 IVSIS3LikeHandleHelper *poS3HandleHelper,
863 ~VSIMultipartWriteHandle()
override;
867 size_t Read(
void *pBuffer,
size_t nBytes)
override;
868 size_t Write(
const void *pBuffer,
size_t nBytes)
override;
870 void ClearErr()
override
884 int Close()
override;
888 return m_pabyBuffer !=
nullptr;
903 IVSIS3LikeFSHandler *m_poFS =
nullptr;
904 std::string m_osFilename{};
905 IVSIS3LikeHandleHelper *m_poS3HandleHelper =
nullptr;
908 CPLHTTPRetryParameters m_oRetryParameters;
911 size_t m_nBufferOff = 0;
912 bool m_bError =
false;
913 bool m_bClosed =
false;
915 CURLM *m_hCurlMulti =
nullptr;
916 CURL *m_hCurl =
nullptr;
917 const void *m_pBuffer =
nullptr;
918 std::string m_osCurlErrBuf{};
919 size_t m_nChunkedBufferOff = 0;
920 size_t m_nChunkedBufferSize = 0;
921 size_t m_nWrittenInPUT = 0;
923 WriteFuncStruct m_sWriteFuncHeaderData{};
925 static size_t ReadCallBackBufferChunked(
char *buffer,
size_t size,
926 size_t nitems,
void *instream);
927 int FinishChunkedTransfer();
931 void InvalidateParentDirectory();
934 VSIChunkedWriteHandle(IVSIS3LikeFSHandler *poFS,
const char *pszFilename,
935 IVSIS3LikeHandleHelper *poS3HandleHelper,
937 ~VSIChunkedWriteHandle()
override;
941 size_t Read(
void *pBuffer,
size_t nBytes)
override;
942 size_t Write(
const void *pBuffer,
size_t nBytes)
override;
944 void ClearErr()
override
958 int Close()
override;
970 VSICurlFilesystemHandlerBase *m_poFS =
nullptr;
971 std::string m_osFSPrefix{};
972 std::string m_osFilename{};
973 CPLHTTPRetryParameters m_oRetryParameters{};
976 int m_nBufferOff = 0;
977 int m_nBufferSize = 0;
978 int m_nBufferOffReadCallback = 0;
979 bool m_bClosed =
false;
980 GByte *m_pabyBuffer =
nullptr;
981 bool m_bError =
false;
983 static size_t ReadCallBackBuffer(
char *buffer,
size_t size,
size_t nitems,
985 virtual bool Send(
bool bIsLastBlock) = 0;
988 VSIAppendWriteHandle(VSICurlFilesystemHandlerBase *poFS,
989 const char *pszFSPrefix,
const char *pszFilename,
991 ~VSIAppendWriteHandle()
override;
995 size_t Read(
void *pBuffer,
size_t nBytes)
override;
996 size_t Write(
const void *pBuffer,
size_t nBytes)
override;
998 void ClearErr()
override
1002 int Error()
override
1012 int Close()
override;
1016 return m_pabyBuffer !=
nullptr;
1024struct VSIDIRWithMissingDirSynthesis :
public VSIDIR
1026 std::vector<std::unique_ptr<VSIDIREntry>> aoEntries{};
1029 ~VSIDIRWithMissingDirSynthesis()
override;
1031 std::vector<std::string> m_aosSubpathsStack{};
1033 void SynthetizeMissingDirectories(
const std::string &osCurSubdir,
1034 bool bAddEntryForThisSubdir);
1041struct VSIDIRS3Like :
public VSIDIRWithMissingDirSynthesis
1043 const std::string m_osDirName;
1045 int nRecurseDepth = 0;
1047 std::string osNextMarker{};
1050 std::string osBucket{};
1051 std::string osObjectKey{};
1052 VSICurlFilesystemHandlerBase *poFS =
nullptr;
1053 IVSIS3LikeFSHandler *poS3FS =
nullptr;
1054 std::unique_ptr<IVSIS3LikeHandleHelper> poHandleHelper{};
1056 bool bCacheEntries =
true;
1057 bool m_bSynthetizeMissingDirectories =
false;
1058 std::string m_osFilterPrefix{};
1064 VSIDIRS3Like(
const std::string &osDirName, IVSIS3LikeFSHandler *poFSIn)
1065 : m_osDirName(osDirName), poFS(poFSIn), poS3FS(poFSIn)
1069 VSIDIRS3Like(
const std::string &osDirName,
1070 VSICurlFilesystemHandlerBase *poFSIn)
1071 : m_osDirName(osDirName), poFS(poFSIn)
1075 VSIDIRS3Like(
const VSIDIRS3Like &) =
delete;
1076 VSIDIRS3Like &operator=(
const VSIDIRS3Like &) =
delete;
1080 virtual bool IssueListDir() = 0;
1088struct CurlRequestHelper
1090 WriteFuncStruct sWriteFuncData{};
1091 WriteFuncStruct sWriteFuncHeaderData{};
1092 char szCurlErrBuf[CURL_ERROR_SIZE + 1] = {};
1094 CurlRequestHelper();
1095 ~CurlRequestHelper();
1096 long perform(CURL *hCurlHandle,
1097 struct curl_slist *headers,
1098 VSICurlFilesystemHandlerBase *poFS,
1099 IVSIS3LikeHandleHelper *poS3HandleHelper);
1106class NetworkStatisticsLogger
1108 static int gnEnabled;
1109 static NetworkStatisticsLogger gInstance;
1111 NetworkStatisticsLogger() =
default;
1113 std::mutex m_mutex{};
1122 GIntBig nGETDownloadedBytes = 0;
1123 GIntBig nPUTUploadedBytes = 0;
1124 GIntBig nPOSTDownloadedBytes = 0;
1125 GIntBig nPOSTUploadedBytes = 0;
1128 enum class ContextPathType
1135 struct ContextPathItem
1137 ContextPathType eType;
1140 ContextPathItem(ContextPathType eTypeIn,
const std::string &osNameIn)
1141 : eType(eTypeIn), osName(osNameIn)
1145 bool operator<(
const ContextPathItem &other)
const
1147 if (
static_cast<int>(eType) <
static_cast<int>(other.eType))
1149 if (
static_cast<int>(eType) >
static_cast<int>(other.eType))
1151 return osName < other.osName;
1157 Counters counters{};
1158 std::map<ContextPathItem, Stats> children{};
1166 std::map<GIntBig, std::vector<ContextPathItem>>
1167 m_mapThreadIdToContextPath{};
1169 static void ReadEnabled();
1171 std::vector<Counters *> GetCountersForContext();
1174 static inline bool IsEnabled()
1180 return gnEnabled == TRUE;
1183 static void EnterFileSystem(
const char *pszName);
1185 static void LeaveFileSystem();
1187 static void EnterFile(
const char *pszName);
1189 static void LeaveFile();
1191 static void EnterAction(
const char *pszName);
1193 static void LeaveAction();
1195 static void LogHEAD();
1197 static void LogGET(
size_t nDownloadedBytes);
1199 static void LogPUT(
size_t nUploadedBytes);
1201 static void LogPOST(
size_t nUploadedBytes,
size_t nDownloadedBytes);
1203 static void LogDELETE();
1205 static void Reset();
1207 static std::string GetReportAsSerializedJSON();
1210struct NetworkStatisticsFileSystem
1212 inline explicit NetworkStatisticsFileSystem(
const char *pszName)
1214 NetworkStatisticsLogger::EnterFileSystem(pszName);
1217 inline ~NetworkStatisticsFileSystem()
1219 NetworkStatisticsLogger::LeaveFileSystem();
1223struct NetworkStatisticsFile
1225 inline explicit NetworkStatisticsFile(
const char *pszName)
1227 NetworkStatisticsLogger::EnterFile(pszName);
1230 inline ~NetworkStatisticsFile()
1232 NetworkStatisticsLogger::LeaveFile();
1236struct NetworkStatisticsAction
1238 inline explicit NetworkStatisticsAction(
const char *pszName)
1240 NetworkStatisticsLogger::EnterAction(pszName);
1243 inline ~NetworkStatisticsAction()
1245 NetworkStatisticsLogger::LeaveAction();
1251int VSICURLGetDownloadChunkSize();
1253void VSICURLInitWriteFuncStruct(cpl::WriteFuncStruct *psStruct,
VSILFILE *fp,
1254 VSICurlReadCbkFunc pfnReadCbk,
1255 void *pReadCbkUserData);
1256size_t VSICurlHandleWriteFunc(
void *buffer,
size_t count,
size_t nmemb,
1258void VSICURLMultiPerform(CURLM *hCurlMultiHandle, CURL *hEasyHandle =
nullptr,
1259 std::atomic<bool> *pbInterrupt =
nullptr);
1260void VSICURLResetHeaderAndWriterFunctions(CURL *hCurlHandle);
1262int VSICurlParseUnixPermissions(
const char *pszPermissions);
1265bool VSICURLGetCachedFileProp(
const char *pszURL, cpl::FileProp &oFileProp);
1266void VSICURLSetCachedFileProp(
const char *pszURL, cpl::FileProp &oFileProp);
1267void VSICURLInvalidateCachedFileProp(
const char *pszURL);
1268void VSICURLInvalidateCachedFilePropPrefix(
const char *pszURL);
1269void VSICURLDestroyCacheFileProp();
1271void VSICURLMultiCleanup(CURLM *hCurlMultiHandle);
The CPLJSONArray class holds JSON object from CPLJSONDocument.
Definition cpl_json.h:60
String list class designed around our use of C "char**" string lists.
Definition cpl_string.h:476
Interface for downloading HTTP, FTP documents.
Interface for read and write JSON documents.
Core portability definitions for CPL.
#define CPL_NON_FINAL
Mark that a class is explicitly recognized as non-final.
Definition cpl_port.h:1094
#define EQUAL(a, b)
Alias for strcasecmp() == 0.
Definition cpl_port.h:532
#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:1101
char ** CSLConstList
Type of a constant null-terminated list of nul terminated strings.
Definition cpl_port.h:1252
unsigned char GByte
Unsigned byte type.
Definition cpl_port.h:165
long long GIntBig
Large signed integer type (generally 64-bit integer type).
Definition cpl_port.h:195
Various convenience functions for working with strings and string lists.
#define VSIStatBufL
Type for VSIStatL()
Definition cpl_vsi.h:232
#define VSI_L_OFFSET_MAX
Maximum value for a file offset.
Definition cpl_vsi.h:138
struct VSIDIR VSIDIR
Opaque type for a directory iterator.
Definition cpl_vsi.h:433
void VSICloseDir(VSIDIR *dir)
Close a directory.
Definition cpl_vsil.cpp:599
GUIntBig vsi_l_offset
Type for a file offset.
Definition cpl_vsi.h:136
Directory entry.
Definition cpl_vsi.h:445
Virtual file handle.
Definition cpl_vsi_virtual.h:48