Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

/vsicurl/: make it work without explicit CPL_VSIL_CURL_USE_HEAD=FALSE with .earthdata.nasa.gov/ URLs (fixes #4641) #4654

Merged
merged 1 commit into from
Oct 14, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions gdal/port/cpl_vsil_curl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,9 @@ static bool VSICurlIsS3LikeSignedURL( const char* pszURL )
((strstr(pszURL, ".s3.amazonaws.com/") != nullptr ||
strstr(pszURL, ".s3.amazonaws.com:") != nullptr ||
strstr(pszURL, ".storage.googleapis.com/") != nullptr ||
strstr(pszURL, ".storage.googleapis.com:") != nullptr) &&
strstr(pszURL, ".storage.googleapis.com:") != nullptr ||
strstr(pszURL, ".cloudfront.net/") != nullptr ||
strstr(pszURL, ".cloudfront.net:") != nullptr) &&
(strstr(pszURL, "&Signature=") != nullptr ||
strstr(pszURL, "?Signature=") != nullptr)) ||
strstr(pszURL, "&X-Amz-Signature=") != nullptr ||
Expand Down Expand Up @@ -1517,7 +1519,13 @@ std::string VSICurlHandle::DownloadRegion( const vsi_l_offset startOffset,
CPLDebug(poFS->GetDebugKey(),
"Got response_code=%ld", response_code);

if( response_code == 403 && bUsedRedirect )
if( bUsedRedirect &&
(response_code == 403 ||
// Below case is in particular for
// gdalinfo /vsicurl/https://lpdaac.earthdata.nasa.gov/lp-prod-protected/HLSS30.015/HLS.S30.T10TEK.2020273T190109.v1.5.B8A.tif --config GDAL_DISABLE_READDIR_ON_OPEN EMPTY_DIR --config GDAL_HTTP_COOKIEFILE /tmp/cookie.txt --config GDAL_HTTP_COOKIEJAR /tmp/cookie.txt
// We got the redirect URL from a HEAD request, but it is not valid for a GET.
// So retry with GET on original URL to get a redirect URL valid for it.
(response_code == 400 && osURL.find(".cloudfront.net") != std::string::npos)) )
{
CPLDebug(poFS->GetDebugKey(),
"Got an error with redirect URL. Retrying with original one");
Expand Down