Go to the documentation of this file.
31 #ifndef CPL_HTTP_H_INCLUDED
32 #define CPL_HTTP_H_INCLUDED
36 #include "cpl_progress.h"
46 #ifndef CPL_HTTP_MAX_RETRY
47 #define CPL_HTTP_MAX_RETRY 0
50 #ifndef CPL_HTTP_RETRY_DELAY
51 #define CPL_HTTP_RETRY_DELAY 30.0
58 typedef struct {
char **papszHeaders;
60 GByte *pabyData;
int nDataLen;
96 typedef size_t (*CPLHTTPFetchWriteFunc)(
void *pBuffer,
size_t nSize,
size_t nMemb,
void *pWriteArg);
102 GDALProgressFunc pfnProgress,
104 CPLHTTPFetchWriteFunc pfnWrite,
108 int nMaxSimultaneous,
126 const char *pszScope );
128 const char *pszScope );
131 const char* pszPrivateKey,
132 const char* pszClientEmail,
133 const char* pszScope,
141 #if defined(__cplusplus) && !defined(CPL_SUPRESS_CPLUSPLUS)
144 void* CPLHTTPSetOptions(
void *pcurl,
const char *pszURL,
const char *
const* papszOptions);
145 char** CPLHTTPGetOptionsFromEnv();
146 double CPLHTTPGetNewRetryDelay(
int response_code,
double dfOldDelay,
147 const char* pszErrBuf,
const char* pszCurlError);
148 void* CPLHTTPIgnoreSigPipe();
149 void CPLHTTPRestoreSigPipeHandler(
void* old_handler);
150 bool CPLMultiPerformWait(
void* hCurlMultiHandle,
int& repeats);
174 ACCESS_TOKEN_FROM_REFRESH,
180 const char* pszClientId,
181 const char* pszClientSecret,
184 const char* pszClientEmail,
185 const char* pszScope,
203 mutable time_t m_nExpirationTime = 0;
221 #endif // __cplusplus
CPLHTTPResult * CPLHTTPFetch(const char *pszURL, CSLConstList papszOptions)
Fetch a document from an url and return in a string.
Definition: cpl_http.cpp:648
unsigned char GByte
Unsigned byte type.
Definition: cpl_port.h:215
const char * GetBearer() const
Return the access token.
Definition: cpl_google_oauth2.cpp:677
const CPLString & GetPrivateKey() const
Returns private key for SERVICE_ACCOUNT method.
Definition: cpl_http.h:195
char * GOA2GetAuthorizationURL(const char *pszScope)
Return authorization url for a given scope.
Definition: cpl_google_oauth2.cpp:127
void CPLHTTPDestroyMultiResult(CPLHTTPResult **papsResults, int nCount)
Clean the memory associated with the return value of CPLHTTPMultiFetch()
Definition: cpl_http.cpp:1474
Manager of Google OAuth2 authentication.
Definition: cpl_http.h:164
int CPLHTTPParseMultipartMime(CPLHTTPResult *psResult)
Parses a MIME multipart message.
Definition: cpl_http.cpp:2127
void CPLHTTPDestroyResult(CPLHTTPResult *psResult)
Clean the memory associated with the return value of CPLHTTPFetch()
Definition: cpl_http.cpp:2094
void CPLHTTPCleanup(void)
Cleanup function to call at application termination.
Definition: cpl_http.cpp:2032
GOA2Manager()
Constructor.
String list class designed around our use of C "char**" string lists.
Definition: cpl_string.h:442
bool CPLIsMachinePotentiallyGCEInstance()
Returns whether the current machine is potentially a Google Compute Engine instance.
Definition: cpl_google_cloud.cpp:110
char * pszContentType
Definition: cpl_http.h:71
Convenient string class based on std::string.
Definition: cpl_string.h:333
bool SetAuthFromRefreshToken(const char *pszRefreshToken, const char *pszClientId, const char *pszClientSecret, CSLConstList papszOptions)
Specifies that the authentication will be done using the OAuth2 client id method.
Definition: cpl_google_oauth2.cpp:595
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:664
#define CPL_C_START
Macro to start a block of C symbols.
Definition: cpl_port.h:337
int nMimePartCount
Definition: cpl_http.h:88
char ** GOA2GetAccessTokenFromCloudEngineVM(CSLConstList papszOptions)
Fetch access token using Cloud Engine internal REST API.
Definition: cpl_google_oauth2.cpp:418
char ** CSLConstList
Type of a constant null-terminated list of nul terminated strings.
Definition: cpl_port.h:1212
CPLHTTPResult ** CPLHTTPMultiFetch(const char *const *papszURL, int nURLCount, int nMaxSimultaneous, CSLConstList papszOptions)
Fetch several documents at once.
Definition: cpl_http.cpp:1227
Definition: cpl_http.h:66
GByte * pabyData
Definition: cpl_http.h:82
#define CPL_C_END
Macro to end a block of C symbols.
Definition: cpl_port.h:339
char ** papszHeaders
Definition: cpl_http.h:85
int CPLHTTPEnabled(void)
Return if CPLHTTP services can be useful.
Definition: cpl_http.cpp:2015
Definition: cpl_http.h:58
bool SetAuthFromServiceAccount(const char *pszPrivateKey, const char *pszClientEmail, const char *pszScope, CSLConstList papszAdditionalClaims, CSLConstList papszOptions)
Specifies that the authentication will be done using the OAuth2 service account method.
Definition: cpl_google_oauth2.cpp:631
AuthMethod
Authentication method.
Definition: cpl_http.h:171
bool CPLIsMachineForSureGCEInstance()
Returns whether the current machine is surely a Google Compute Engine instance.
Definition: cpl_google_cloud.cpp:58
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
char * GOA2GetAccessToken(const char *pszRefreshToken, const char *pszScope)
Fetch access token using refresh token.
Definition: cpl_google_oauth2.cpp:387
bool SetAuthFromGCE(CSLConstList papszOptions)
Specifies that the authentication will be done using the local credentials of the current Google Comp...
Definition: cpl_google_oauth2.cpp:570
char * pszErrBuf
Definition: cpl_http.h:74
int nStatus
Definition: cpl_http.h:68
int nDataLen
Definition: cpl_http.h:77
char * GOA2GetRefreshToken(const char *pszAuthToken, const char *pszScope)
Turn Auth Token into a Refresh Token.
Definition: cpl_google_oauth2.cpp:164
const CPLString & GetClientEmail() const
Returns client email for SERVICE_ACCOUNT method.
Definition: cpl_http.h:198
int nDataAlloc
Definition: cpl_http.h:79
CPLMimePart * pasMimePart
Definition: cpl_http.h:91
AuthMethod GetAuthMethod() const
Returns the authentication method.
Definition: cpl_http.h:190