OGR
|
Go to the source code of this file.
Classes | |
struct | CPLMimePart |
struct | CPLHTTPResult |
Functions | |
int | CPLHTTPEnabled (void) |
Return if CPLHTTP services can be useful. More... | |
CPLHTTPResult * | CPLHTTPFetch (const char *pszURL, char **papszOptions) |
Fetch a document from an url and return in a string. More... | |
void | CPLHTTPCleanup (void) |
Cleanup function to call at application termination. | |
void | CPLHTTPDestroyResult (CPLHTTPResult *psResult) |
Clean the memory associated with the return value of CPLHTTPFetch() More... | |
int | CPLHTTPParseMultipartMime (CPLHTTPResult *psResult) |
Parses a MIME multipart message. More... | |
char * | GOA2GetAuthorizationURL (const char *pszScope) |
char * | GOA2GetRefreshToken (const char *pszAuthToken, const char *pszScope) |
char * | GOA2GetAccessToken (const char *pszRefreshToken, const char *pszScope) |
Interface for downloading HTTP, FTP documents
void CPLHTTPDestroyResult | ( | CPLHTTPResult * | psResult | ) |
Clean the memory associated with the return value of CPLHTTPFetch()
psResult | pointer to the return value of CPLHTTPFetch() |
References CPLFree, CSLDestroy(), CPLHTTPResult::nMimePartCount, CPLHTTPResult::pabyData, CPLMimePart::papszHeaders, CPLHTTPResult::papszHeaders, CPLHTTPResult::pasMimePart, CPLHTTPResult::pszContentType, and CPLHTTPResult::pszErrBuf.
int CPLHTTPEnabled | ( | void | ) |
Return if CPLHTTP services can be useful.
Those services depend on GDAL being build with libcurl support.
CPLHTTPResult* CPLHTTPFetch | ( | const char * | pszURL, |
char ** | papszOptions | ||
) |
Fetch a document from an url and return in a string.
pszURL | valid URL recognized by underlying download library (libcurl) |
papszOptions | option list as a NULL-terminated array of strings. May be NULL. The following options are handled :
|
Alternatively, if not defined in the papszOptions arguments, the CONNECTTIMEOUT, TIMEOUT, LOW_SPEED_TIME, LOW_SPEED_LIMIT, PROXY, PROXYUSERPWD, PROXYAUTH, NETRC, MAX_RETRY and RETRY_DELAY, HEADER_FILE values are searched in the configuration options named GDAL_HTTP_CONNECTTIMEOUT, GDAL_HTTP_TIMEOUT, GDAL_HTTP_LOW_SPEED_TIME, GDAL_HTTP_LOW_SPEED_LIMIT, GDAL_HTTP_PROXY, GDAL_HTTP_PROXYUSERPWD, GDAL_PROXY_AUTH, GDAL_HTTP_NETRC, GDAL_HTTP_MAX_RETRY, GDAL_HTTP_RETRY_DELAY, GDAL_HTTP_HEADER_FILE.
References CPLCalloc(), CPLDebug(), CPLError(), CPLGetConfigOption(), CPLSPrintf(), CPLStrdup(), CPLTestBool(), CSLFetchNameValue(), CPLHTTPResult::nStatus, CPLHTTPResult::pszErrBuf, STARTS_WITH, and VSIGetMemFileBuffer().
Referenced by GOA2GetAccessToken(), and GOA2GetRefreshToken().
int CPLHTTPParseMultipartMime | ( | CPLHTTPResult * | psResult | ) |
Parses a MIME multipart message.
This function will iterate over each part and put it in a separate element of the pasMimePart array of the provided psResult structure.
psResult | pointer to the return value of CPLHTTPFetch() |
References CPLError(), CPLHTTPResult::nMimePartCount, and CPLHTTPResult::pszContentType.
char* GOA2GetAccessToken | ( | const char * | pszRefreshToken, |
const char * | pszScope | ||
) |
Fetch access token using refresh token.
The permanent refresh token is used to fetch a temporary (usually one hour) access token using Google OAuth2 web services.
A CPLError will be reported if the request fails for some reason. Common reasons include the refresh token having been revoked by the user or http connection problems.
pszRefreshToken | the refresh token from GOA2GetRefreshToken(). |
pszScope | the scope for which it is valid. Currently unused |
References CPLStringList::AddString(), CPLDebug(), CPLError(), CPLGetConfigOption(), CPLHTTPFetch(), CPLHTTPResult::pabyData, CPLString::Printf(), and CPLHTTPResult::pszErrBuf.
char* GOA2GetAuthorizationURL | ( | const char * | pszScope | ) |
Return authorization url for a given scope.
Returns the URL that a user should visit, and use for authentication in order to get an "auth token" indicating their willingness to use a service.
Note that when the user visits this url they will be asked to login (using a google/gmail/etc) account, and to authorize use of the requested scope for the application "GDAL/OGR". Once they have done so, they will be presented with a lengthy string they should "enter into their application". This is the "auth token" to be passed to GOA2GetRefreshToken(). The "auth token" can only be used once.
This function should never fail.
pszScope | the service being requested, not yet URL encoded, such as "https://www.googleapis.com/auth/fusiontables". |
References CPLES_URL, CPLEscapeString(), CPLGetConfigOption(), CPLStrdup(), CPLString::Printf(), and CPLString::Seize().
Referenced by GOA2GetRefreshToken().
char* GOA2GetRefreshToken | ( | const char * | pszAuthToken, |
const char * | pszScope | ||
) |
Turn Auth Token into a Refresh Token.
A one time "auth token" provided by the user is turned into a reusable "refresh token" using a google oauth2 web service.
A CPLError will be reported if the translation fails for some reason. Common reasons include the auth token already having been used before, it not being appropriate for the passed scope and configured client api or http connection problems. NULL is returned on error.
pszAuthToken | the authorization token from the user. |
pszScope | the scope for which it is valid. |
References CPLStringList::AddString(), CPLError(), CPLGetConfigOption(), CPLHTTPFetch(), GOA2GetAuthorizationURL(), CPLHTTPResult::pabyData, CPLString::Printf(), and CPLString::Seize().