31 #ifndef CPL_HTTP_H_INCLUDED 32 #define CPL_HTTP_H_INCLUDED 36 #include "cpl_progress.h" 46 #define CPL_HTTP_MAX_RETRY 0 47 #define CPL_HTTP_RETRY_DELAY 30.0 53 typedef struct {
char **papszHeaders;
55 GByte *pabyData;
int nDataLen;
91 typedef size_t (*CPLHTTPFetchWriteFunc)(
void *pBuffer,
size_t nSize,
size_t nMemb,
void *pWriteArg);
97 GDALProgressFunc pfnProgress,
99 CPLHTTPFetchWriteFunc pfnWrite,
103 int nMaxSimultaneous,
121 const char *pszScope );
123 const char *pszScope );
126 const char* pszPrivateKey,
127 const char* pszClientEmail,
128 const char* pszScope,
136 #if defined(__cplusplus) && !defined(CPL_SUPRESS_CPLUSPLUS) 139 void* CPLHTTPSetOptions(
void *pcurl,
const char *pszURL,
const char *
const* papszOptions);
140 char** CPLHTTPGetOptionsFromEnv();
141 double CPLHTTPGetNewRetryDelay(
int response_code,
double dfOldDelay,
const char* pszErrBuf);
142 void* CPLHTTPIgnoreSigPipe();
143 void CPLHTTPRestoreSigPipeHandler(
void* old_handler);
144 bool CPLMultiPerformWait(
void* hCurlMultiHandle,
int& repeats);
168 ACCESS_TOKEN_FROM_REFRESH,
173 bool SetAuthFromRefreshToken(
const char* pszRefreshToken,
174 const char* pszClientId,
175 const char* pszClientSecret,
177 bool SetAuthFromServiceAccount(
const char* pszPrivateKey,
178 const char* pszClientEmail,
179 const char* pszScope,
186 const char* GetBearer()
const;
197 mutable time_t m_nExpirationTime = 0;
198 AuthMethod m_eMethod = NONE;
215 #endif // __cplusplus AuthMethod GetAuthMethod() const
Returns the authentication method.
Definition: cpl_http.h:184
CPLMimePart * pasMimePart
Definition: cpl_http.h:86
CPLHTTPResult * CPLHTTPFetch(const char *pszURL, CSLConstList papszOptions)
Fetch a document from an url and return in a string.
Definition: cpl_http.cpp:631
#define CPL_C_START
Macro to start a block of C symbols.
Definition: cpl_port.h:337
bool CPLIsMachineForSureGCEInstance()
Returns whether the current machine is surely a Google Compute Engine instance.
Definition: cpl_google_cloud.cpp:58
void CPLHTTPCleanup(void)
Cleanup function to call at application termination.
Definition: cpl_http.cpp:1907
char * pszContentType
Definition: cpl_http.h:66
int CPLHTTPParseMultipartMime(CPLHTTPResult *psResult)
Parses a MIME multipart message.
Definition: cpl_http.cpp:2002
void CPLHTTPDestroyResult(CPLHTTPResult *psResult)
Clean the memory associated with the return value of CPLHTTPFetch()
Definition: cpl_http.cpp:1969
CPLHTTPResult * CPLHTTPFetchEx(const char *pszURL, CSLConstList papszOptions, GDALProgressFunc pfnProgress, void *pProgressArg, CPLHTTPFetchWriteFunc pfnWrite, void *pWriteArg)
Fetch a document from an url and return in a string.
Definition: cpl_http.cpp:647
unsigned char GByte
Unsigned byte type.
Definition: cpl_port.h:215
char ** papszHeaders
Definition: cpl_http.h:80
Convenient string class based on std::string.
Definition: cpl_string.h:329
char ** GOA2GetAccessTokenFromCloudEngineVM(CSLConstList papszOptions)
Fetch access token using Cloud Engine internal REST API.
Definition: cpl_google_oauth2.cpp:418
CPLHTTPResult ** CPLHTTPMultiFetch(const char *const *papszURL, int nURLCount, int nMaxSimultaneous, CSLConstList papszOptions)
Fetch several documents at once.
Definition: cpl_http.cpp:1118
char * GOA2GetAccessToken(const char *pszRefreshToken, const char *pszScope)
Fetch access token using refresh token.
Definition: cpl_google_oauth2.cpp:387
Various convenience functions for working with strings and string lists.
int CPLHTTPEnabled(void)
Return if CPLHTTP services can be useful.
Definition: cpl_http.cpp:1890
char ** CSLConstList
Type of a constant null-terminated list of nul terminated strings.
Definition: cpl_port.h:1186
int nMimePartCount
Definition: cpl_http.h:83
void CPLHTTPDestroyMultiResult(CPLHTTPResult **papsResults, int nCount)
Clean the memory associated with the return value of CPLHTTPMultiFetch()
Definition: cpl_http.cpp:1365
String list class designed around our use of C "char**" string lists.
Definition: cpl_string.h:438
int nDataAlloc
Definition: cpl_http.h:74
int nDataLen
Definition: cpl_http.h:72
const CPLString & GetClientEmail() const
Returns client email for SERVICE_ACCOUNT method.
Definition: cpl_http.h:192
Various convenience functions for CPL.
AuthMethod
Authentication method.
Definition: cpl_http.h:164
bool CPLIsMachinePotentiallyGCEInstance()
Returns whether the current machine is potentially a Google Compute Engine instance.
Definition: cpl_google_cloud.cpp:110
Definition: cpl_http.h:61
int nStatus
Definition: cpl_http.h:63
Manager of Google OAuth2 authentication.
Definition: cpl_http.h:157
char ** GOA2GetAccessTokenFromServiceAccount(const char *pszPrivateKey, const char *pszClientEmail, const char *pszScope, CSLConstList papszAdditionalClaims, CSLConstList papszOptions)
Fetch access token using Service Account OAuth2.
Definition: cpl_google_oauth2.cpp:459
GByte * pabyData
Definition: cpl_http.h:77
Definition: cpl_http.h:53
#define CPL_C_END
Macro to end a block of C symbols.
Definition: cpl_port.h:339
char * pszErrBuf
Definition: cpl_http.h:69
const CPLString & GetPrivateKey() const
Returns private key for SERVICE_ACCOUNT method.
Definition: cpl_http.h:189
char * GOA2GetRefreshToken(const char *pszAuthToken, const char *pszScope)
Turn Auth Token into a Refresh Token.
Definition: cpl_google_oauth2.cpp:164
char * GOA2GetAuthorizationURL(const char *pszScope)
Return authorization url for a given scope.
Definition: cpl_google_oauth2.cpp:127