Sample code for 30+ languages & platforms
PowerBuilder Requires Chilkat v11.6.0+

S3 Http: Read Object Checksums and Encryption Metadata

See more S3 - HTTP Examples

Uses Chilkat.Http with Amazon S3 general purpose buckets and Signature Version 4. These examples do not cover directory buckets/S3 Express, access-point ARNs, Outposts, or other specialized endpoints. They target the commercial AWS partition; other partitions need their documented endpoint suffix.

Load private qa_data/aws/s3.json containing nonempty string fields access_key and secret_key, plus session_token for temporary credentials. Prefer short-lived role credentials. These samples do not discover AWS profiles or refresh credentials. Set the bucket's actual region and replace sample bucket names and object keys. TLS certificate verification is explicitly enabled. Keep detailed HTTP diagnostics private because they can contain credentials or presigned URLs.

Uses explicit signed Http requests to preserve query parameters, conditional headers, and full responses. The included SigV4 block signs the exact path, sorted encoded query and headers used by this example; it is not a general-purpose HTTP signing library. Keep the clock accurate and do not change signed data after signing. Code requires Chilkat 11.6.0 or later; locally tested with 11.8.0.

HEAD with x-amz-checksum-mode=ENABLED returns available stored checksums and their type without downloading the body. An absent algorithm is not an empty checksum. FULL_OBJECT and COMPOSITE must be interpreted differently; do not compare a whole-file SHA-256 with a composite hash. ETag is an opaque validator.

Requires s3:GetObject or s3:GetObjectVersion. KMS checksum retrieval can require kms:Decrypt and kms:GenerateDataKey. A 403 does not establish absence. No PUT encryption headers are sent on HEAD.

AWS reference

Chilkat PowerBuilder Downloads

PowerBuilder
integer li_rc
long li_Success
oleobject loo_StringCompare
oleobject loo_Credentials
long li_StringMatch1
long li_StringMatch2
oleobject loo_Http
long li_StringMatch3
string ls_Region
oleobject loo_Endpoint
string ls_BucketName
string ls_ObjectKey
oleobject loo_Response
oleobject loo_Signer
oleobject loo_Now
oleobject loo_Timestamp
oleobject loo_Canonical
oleobject loo_CanonicalHeaders
oleobject loo_SignedHeaders
oleobject loo_Scope
oleobject loo_StringToSign
oleobject loo_SigningKey
oleobject loo_Authorization
oleobject loo_Url
oleobject loo_Query
oleobject loo_Number
oleobject loo_Host
oleobject loo_Uri
oleobject loo_Xml
string ls_AmzDate
string ls_DateStamp
string ls_PayloadHash
string ls_CanonicalHash
string ls_DerivedKey
string ls_Signature
long li_ReplaceCount
string ls_VersionId
string ls_Value
long li_StringMatch4

li_Success = 0

loo_StringCompare = create oleobject
li_rc = loo_StringCompare.ConnectToNewObject("Chilkat.StringBuilder")
if li_rc < 0 then
    destroy loo_StringCompare
    MessageBox("Error","Connecting to COM object failed")
    return
end if
//  This example requires the Chilkat API to have been previously unlocked.
//  See Global Unlock Sample for sample code.
//  Load private credentials; never put access keys or session tokens in source.
loo_Credentials = create oleobject
li_rc = loo_Credentials.ConnectToNewObject("Chilkat.JsonObject")

loo_Credentials.Strict = 1
li_Success = loo_Credentials.LoadFile("qa_data/aws/s3.json")
if li_Success <> 1 then
    Write-Debug "Could not load private S3 credentials."
    destroy loo_StringCompare
    destroy loo_Credentials
    return
end if

loo_StringCompare.SetString(loo_Credentials.StringOf("access_key"))
li_StringMatch1 = loo_StringCompare.ContentsEqual("",1)
if (loo_Credentials.JsonTypeOf("access_key") <> 1) OR (li_StringMatch1 = 1) then
    Write-Debug "Missing or invalid access_key."
    destroy loo_StringCompare
    destroy loo_Credentials
    return
end if

loo_StringCompare.SetString(loo_Credentials.StringOf("secret_key"))
li_StringMatch2 = loo_StringCompare.ContentsEqual("",1)
if (loo_Credentials.JsonTypeOf("secret_key") <> 1) OR (li_StringMatch2 = 1) then
    Write-Debug "Missing or invalid secret_key."
    destroy loo_StringCompare
    destroy loo_Credentials
    return
end if

loo_Http = create oleobject
li_rc = loo_Http.ConnectToNewObject("Chilkat.Http")

loo_Http.AwsAccessKey = loo_Credentials.StringOf("access_key")
loo_Http.AwsSecretKey = loo_Credentials.StringOf("secret_key")
if loo_Credentials.HasMember("session_token") = 1 then
    loo_StringCompare.SetString(loo_Credentials.StringOf("session_token"))
    li_StringMatch3 = loo_StringCompare.ContentsEqual("",1)
    if (loo_Credentials.JsonTypeOf("session_token") <> 1) OR (li_StringMatch3 = 1) then
        Write-Debug "session_token must be a nonempty string when supplied."
        destroy loo_StringCompare
        destroy loo_Credentials
        destroy loo_Http
        return
    end if

    loo_Http.AwsSessionToken = loo_Credentials.StringOf("session_token")
end if

//  Current Chilkat uses SigV4 by default. Do not select deprecated SigV2.
//  Set the actual bucket region, not the caller's location.
ls_Region = "us-west-2"
loo_Http.AwsRegion = ls_Region
loo_Endpoint = create oleobject
li_rc = loo_Endpoint.ConnectToNewObject("Chilkat.StringBuilder")

loo_Endpoint.Append("s3.")
loo_Endpoint.Append(ls_Region)
loo_Endpoint.Append(".amazonaws.com")
loo_Http.AwsEndpoint = loo_Endpoint.GetAsString()
loo_Http.RequireSslCertVerify = 1
loo_Http.FollowRedirects = 0
//  A region redirect is not success. Correct the endpoint and signing region.
ls_BucketName = "your-bucket-name"
ls_ObjectKey = "examples/archive.bin"
loo_Response = create oleobject
li_rc = loo_Response.ConnectToNewObject("Chilkat.HttpResponse")

loo_Signer = create oleobject
li_rc = loo_Signer.ConnectToNewObject("Chilkat.Crypt2")

loo_Signer.Charset = "utf-8"
loo_Signer.HashAlgorithm = "sha256"
loo_Signer.EncodingMode = "hexlower"
loo_Signer.MacAlgorithm = "hmac"
loo_Now = create oleobject
li_rc = loo_Now.ConnectToNewObject("Chilkat.CkDateTime")

loo_Timestamp = create oleobject
li_rc = loo_Timestamp.ConnectToNewObject("Chilkat.StringBuilder")

loo_Canonical = create oleobject
li_rc = loo_Canonical.ConnectToNewObject("Chilkat.StringBuilder")

loo_CanonicalHeaders = create oleobject
li_rc = loo_CanonicalHeaders.ConnectToNewObject("Chilkat.StringBuilder")

loo_SignedHeaders = create oleobject
li_rc = loo_SignedHeaders.ConnectToNewObject("Chilkat.StringBuilder")

loo_Scope = create oleobject
li_rc = loo_Scope.ConnectToNewObject("Chilkat.StringBuilder")

loo_StringToSign = create oleobject
li_rc = loo_StringToSign.ConnectToNewObject("Chilkat.StringBuilder")

loo_SigningKey = create oleobject
li_rc = loo_SigningKey.ConnectToNewObject("Chilkat.StringBuilder")

loo_Authorization = create oleobject
li_rc = loo_Authorization.ConnectToNewObject("Chilkat.StringBuilder")

loo_Url = create oleobject
li_rc = loo_Url.ConnectToNewObject("Chilkat.StringBuilder")

loo_Query = create oleobject
li_rc = loo_Query.ConnectToNewObject("Chilkat.StringBuilder")

loo_Number = create oleobject
li_rc = loo_Number.ConnectToNewObject("Chilkat.StringBuilder")

loo_Host = create oleobject
li_rc = loo_Host.ConnectToNewObject("Chilkat.StringBuilder")

loo_Uri = create oleobject
li_rc = loo_Uri.ConnectToNewObject("Chilkat.StringBuilder")

loo_Xml = create oleobject
li_rc = loo_Xml.ConnectToNewObject("Chilkat.Xml")

loo_Host.Append(ls_BucketName)
loo_Host.Append(".")
loo_Host.Append(loo_Endpoint.GetAsString())
//  Encode the original key exactly once, preserving S3 path separators.
loo_Uri.SetString(loo_Http.UrlEncode(ls_ObjectKey))
li_ReplaceCount = loo_Uri.ReplaceNoCase("%2f","/")
if (loo_Uri.StartsWith("/",1) = 1) OR (loo_Uri.Contains("/../",1) = 1) OR (loo_Uri.Contains("/./",1) = 1) then
    Write-Debug "Use a key without a leading slash or dot path segments for these examples."
    destroy loo_StringCompare
    destroy loo_Credentials
    destroy loo_Http
    destroy loo_Endpoint
    destroy loo_Response
    destroy loo_Signer
    destroy loo_Now
    destroy loo_Timestamp
    destroy loo_Canonical
    destroy loo_CanonicalHeaders
    destroy loo_SignedHeaders
    destroy loo_Scope
    destroy loo_StringToSign
    destroy loo_SigningKey
    destroy loo_Authorization
    destroy loo_Url
    destroy loo_Query
    destroy loo_Number
    destroy loo_Host
    destroy loo_Uri
    destroy loo_Xml
    return
end if

loo_Uri.Prepend("/")
ls_VersionId = ""

loo_Query.Clear()
loo_StringCompare.SetString(ls_VersionId)
li_StringMatch4 = loo_StringCompare.ContentsEqual("",1)
if li_StringMatch4 <> 1 then
    if loo_Query.Length > 0 then
        loo_Query.Append("&")
    end if

    loo_Query.Append("versionId=")
    loo_Query.Append(loo_Http.UrlEncode(ls_VersionId))
end if

loo_Http.ClearHeaders()
li_Success = loo_Now.SetFromCurrentSystemTime()
if li_Success <> 1 then
    Write-Debug "Could not read system time."
    destroy loo_StringCompare
    destroy loo_Credentials
    destroy loo_Http
    destroy loo_Endpoint
    destroy loo_Response
    destroy loo_Signer
    destroy loo_Now
    destroy loo_Timestamp
    destroy loo_Canonical
    destroy loo_CanonicalHeaders
    destroy loo_SignedHeaders
    destroy loo_Scope
    destroy loo_StringToSign
    destroy loo_SigningKey
    destroy loo_Authorization
    destroy loo_Url
    destroy loo_Query
    destroy loo_Number
    destroy loo_Host
    destroy loo_Uri
    destroy loo_Xml
    return
end if

loo_Timestamp.SetString(loo_Now.GetAsTimestamp(0))
li_ReplaceCount = loo_Timestamp.Replace("-","")
li_ReplaceCount = loo_Timestamp.Replace(":","")
ls_AmzDate = loo_Timestamp.GetAsString()
ls_DateStamp = loo_Timestamp.GetRange(0,8,0)
ls_PayloadHash = loo_Signer.HashStringENC("")
if loo_Signer.LastMethodSuccess <> 1 then
    Write-Debug "Could not hash payload."
    destroy loo_StringCompare
    destroy loo_Credentials
    destroy loo_Http
    destroy loo_Endpoint
    destroy loo_Response
    destroy loo_Signer
    destroy loo_Now
    destroy loo_Timestamp
    destroy loo_Canonical
    destroy loo_CanonicalHeaders
    destroy loo_SignedHeaders
    destroy loo_Scope
    destroy loo_StringToSign
    destroy loo_SigningKey
    destroy loo_Authorization
    destroy loo_Url
    destroy loo_Query
    destroy loo_Number
    destroy loo_Host
    destroy loo_Uri
    destroy loo_Xml
    return
end if

loo_CanonicalHeaders.Clear()
loo_SignedHeaders.Clear()
if loo_SignedHeaders.Length > 0 then
    loo_SignedHeaders.Append(";")
end if

loo_SignedHeaders.Append("host")
loo_CanonicalHeaders.Append("host:")
loo_CanonicalHeaders.Append(loo_Host.GetAsString())
loo_CanonicalHeaders.Append("~n")
loo_Http.SetRequestHeader("host",loo_Host.GetAsString())
if loo_SignedHeaders.Length > 0 then
    loo_SignedHeaders.Append(";")
end if

loo_SignedHeaders.Append("x-amz-checksum-mode")
loo_CanonicalHeaders.Append("x-amz-checksum-mode:")
loo_CanonicalHeaders.Append("ENABLED")
loo_CanonicalHeaders.Append("~n")
loo_Http.SetRequestHeader("x-amz-checksum-mode","ENABLED")
if loo_SignedHeaders.Length > 0 then
    loo_SignedHeaders.Append(";")
end if

loo_SignedHeaders.Append("x-amz-content-sha256")
loo_CanonicalHeaders.Append("x-amz-content-sha256:")
loo_CanonicalHeaders.Append(ls_PayloadHash)
loo_CanonicalHeaders.Append("~n")
loo_Http.SetRequestHeader("x-amz-content-sha256",ls_PayloadHash)
if loo_SignedHeaders.Length > 0 then
    loo_SignedHeaders.Append(";")
end if

loo_SignedHeaders.Append("x-amz-date")
loo_CanonicalHeaders.Append("x-amz-date:")
loo_CanonicalHeaders.Append(ls_AmzDate)
loo_CanonicalHeaders.Append("~n")
loo_Http.SetRequestHeader("x-amz-date",ls_AmzDate)
if loo_Credentials.HasMember("session_token") = 1 then
    if loo_SignedHeaders.Length > 0 then
        loo_SignedHeaders.Append(";")
    end if

    loo_SignedHeaders.Append("x-amz-security-token")
    loo_CanonicalHeaders.Append("x-amz-security-token:")
    loo_CanonicalHeaders.Append(loo_Credentials.StringOf("session_token"))
    loo_CanonicalHeaders.Append("~n")
    loo_Http.SetRequestHeader("x-amz-security-token",loo_Credentials.StringOf("session_token"))
end if

loo_Canonical.Clear()
loo_Canonical.Append("HEAD~n")
loo_Canonical.Append(loo_Uri.GetAsString())
loo_Canonical.Append("~n")
loo_Canonical.Append(loo_Query.GetAsString())
loo_Canonical.Append("~n")
loo_Canonical.Append(loo_CanonicalHeaders.GetAsString())
loo_Canonical.Append("~n")
loo_Canonical.Append(loo_SignedHeaders.GetAsString())
loo_Canonical.Append("~n")
loo_Canonical.Append(ls_PayloadHash)
ls_CanonicalHash = loo_Signer.HashStringENC(loo_Canonical.GetAsString())
if loo_Signer.LastMethodSuccess <> 1 then
    Write-Debug "Could not hash canonical request."
    destroy loo_StringCompare
    destroy loo_Credentials
    destroy loo_Http
    destroy loo_Endpoint
    destroy loo_Response
    destroy loo_Signer
    destroy loo_Now
    destroy loo_Timestamp
    destroy loo_Canonical
    destroy loo_CanonicalHeaders
    destroy loo_SignedHeaders
    destroy loo_Scope
    destroy loo_StringToSign
    destroy loo_SigningKey
    destroy loo_Authorization
    destroy loo_Url
    destroy loo_Query
    destroy loo_Number
    destroy loo_Host
    destroy loo_Uri
    destroy loo_Xml
    return
end if

loo_Scope.Clear()
loo_Scope.Append(ls_DateStamp)
loo_Scope.Append("/")
loo_Scope.Append(ls_Region)
loo_Scope.Append("/s3/aws4_request")
loo_StringToSign.Clear()
loo_StringToSign.Append("AWS4-HMAC-SHA256~n")
loo_StringToSign.Append(ls_AmzDate)
loo_StringToSign.Append("~n")
loo_StringToSign.Append(loo_Scope.GetAsString())
loo_StringToSign.Append("~n")
loo_StringToSign.Append(ls_CanonicalHash)
loo_SigningKey.SetString("AWS4")
loo_SigningKey.Append(loo_Credentials.StringOf("secret_key"))
li_Success = loo_Signer.SetMacKeyString(loo_SigningKey.GetAsString())
if li_Success <> 1 then
    Write-Debug "Could not set signing key."
    destroy loo_StringCompare
    destroy loo_Credentials
    destroy loo_Http
    destroy loo_Endpoint
    destroy loo_Response
    destroy loo_Signer
    destroy loo_Now
    destroy loo_Timestamp
    destroy loo_Canonical
    destroy loo_CanonicalHeaders
    destroy loo_SignedHeaders
    destroy loo_Scope
    destroy loo_StringToSign
    destroy loo_SigningKey
    destroy loo_Authorization
    destroy loo_Url
    destroy loo_Query
    destroy loo_Number
    destroy loo_Host
    destroy loo_Uri
    destroy loo_Xml
    return
end if

ls_DerivedKey = loo_Signer.MacStringENC(ls_DateStamp)
if loo_Signer.LastMethodSuccess <> 1 then
    Write-Debug "Could not derive signing key."
    destroy loo_StringCompare
    destroy loo_Credentials
    destroy loo_Http
    destroy loo_Endpoint
    destroy loo_Response
    destroy loo_Signer
    destroy loo_Now
    destroy loo_Timestamp
    destroy loo_Canonical
    destroy loo_CanonicalHeaders
    destroy loo_SignedHeaders
    destroy loo_Scope
    destroy loo_StringToSign
    destroy loo_SigningKey
    destroy loo_Authorization
    destroy loo_Url
    destroy loo_Query
    destroy loo_Number
    destroy loo_Host
    destroy loo_Uri
    destroy loo_Xml
    return
end if

li_Success = loo_Signer.SetMacKeyEncoded(ls_DerivedKey,"hex")
if li_Success <> 1 then
    Write-Debug "Could not set signing key."
    destroy loo_StringCompare
    destroy loo_Credentials
    destroy loo_Http
    destroy loo_Endpoint
    destroy loo_Response
    destroy loo_Signer
    destroy loo_Now
    destroy loo_Timestamp
    destroy loo_Canonical
    destroy loo_CanonicalHeaders
    destroy loo_SignedHeaders
    destroy loo_Scope
    destroy loo_StringToSign
    destroy loo_SigningKey
    destroy loo_Authorization
    destroy loo_Url
    destroy loo_Query
    destroy loo_Number
    destroy loo_Host
    destroy loo_Uri
    destroy loo_Xml
    return
end if

ls_DerivedKey = loo_Signer.MacStringENC(ls_Region)
if loo_Signer.LastMethodSuccess <> 1 then
    Write-Debug "Could not derive signing key."
    destroy loo_StringCompare
    destroy loo_Credentials
    destroy loo_Http
    destroy loo_Endpoint
    destroy loo_Response
    destroy loo_Signer
    destroy loo_Now
    destroy loo_Timestamp
    destroy loo_Canonical
    destroy loo_CanonicalHeaders
    destroy loo_SignedHeaders
    destroy loo_Scope
    destroy loo_StringToSign
    destroy loo_SigningKey
    destroy loo_Authorization
    destroy loo_Url
    destroy loo_Query
    destroy loo_Number
    destroy loo_Host
    destroy loo_Uri
    destroy loo_Xml
    return
end if

li_Success = loo_Signer.SetMacKeyEncoded(ls_DerivedKey,"hex")
if li_Success <> 1 then
    Write-Debug "Could not set signing key."
    destroy loo_StringCompare
    destroy loo_Credentials
    destroy loo_Http
    destroy loo_Endpoint
    destroy loo_Response
    destroy loo_Signer
    destroy loo_Now
    destroy loo_Timestamp
    destroy loo_Canonical
    destroy loo_CanonicalHeaders
    destroy loo_SignedHeaders
    destroy loo_Scope
    destroy loo_StringToSign
    destroy loo_SigningKey
    destroy loo_Authorization
    destroy loo_Url
    destroy loo_Query
    destroy loo_Number
    destroy loo_Host
    destroy loo_Uri
    destroy loo_Xml
    return
end if

ls_DerivedKey = loo_Signer.MacStringENC("s3")
if loo_Signer.LastMethodSuccess <> 1 then
    Write-Debug "Could not derive signing key."
    destroy loo_StringCompare
    destroy loo_Credentials
    destroy loo_Http
    destroy loo_Endpoint
    destroy loo_Response
    destroy loo_Signer
    destroy loo_Now
    destroy loo_Timestamp
    destroy loo_Canonical
    destroy loo_CanonicalHeaders
    destroy loo_SignedHeaders
    destroy loo_Scope
    destroy loo_StringToSign
    destroy loo_SigningKey
    destroy loo_Authorization
    destroy loo_Url
    destroy loo_Query
    destroy loo_Number
    destroy loo_Host
    destroy loo_Uri
    destroy loo_Xml
    return
end if

li_Success = loo_Signer.SetMacKeyEncoded(ls_DerivedKey,"hex")
if li_Success <> 1 then
    Write-Debug "Could not set signing key."
    destroy loo_StringCompare
    destroy loo_Credentials
    destroy loo_Http
    destroy loo_Endpoint
    destroy loo_Response
    destroy loo_Signer
    destroy loo_Now
    destroy loo_Timestamp
    destroy loo_Canonical
    destroy loo_CanonicalHeaders
    destroy loo_SignedHeaders
    destroy loo_Scope
    destroy loo_StringToSign
    destroy loo_SigningKey
    destroy loo_Authorization
    destroy loo_Url
    destroy loo_Query
    destroy loo_Number
    destroy loo_Host
    destroy loo_Uri
    destroy loo_Xml
    return
end if

ls_DerivedKey = loo_Signer.MacStringENC("aws4_request")
if loo_Signer.LastMethodSuccess <> 1 then
    Write-Debug "Could not derive signing key."
    destroy loo_StringCompare
    destroy loo_Credentials
    destroy loo_Http
    destroy loo_Endpoint
    destroy loo_Response
    destroy loo_Signer
    destroy loo_Now
    destroy loo_Timestamp
    destroy loo_Canonical
    destroy loo_CanonicalHeaders
    destroy loo_SignedHeaders
    destroy loo_Scope
    destroy loo_StringToSign
    destroy loo_SigningKey
    destroy loo_Authorization
    destroy loo_Url
    destroy loo_Query
    destroy loo_Number
    destroy loo_Host
    destroy loo_Uri
    destroy loo_Xml
    return
end if

li_Success = loo_Signer.SetMacKeyEncoded(ls_DerivedKey,"hex")
if li_Success <> 1 then
    Write-Debug "Could not set signing key."
    destroy loo_StringCompare
    destroy loo_Credentials
    destroy loo_Http
    destroy loo_Endpoint
    destroy loo_Response
    destroy loo_Signer
    destroy loo_Now
    destroy loo_Timestamp
    destroy loo_Canonical
    destroy loo_CanonicalHeaders
    destroy loo_SignedHeaders
    destroy loo_Scope
    destroy loo_StringToSign
    destroy loo_SigningKey
    destroy loo_Authorization
    destroy loo_Url
    destroy loo_Query
    destroy loo_Number
    destroy loo_Host
    destroy loo_Uri
    destroy loo_Xml
    return
end if

ls_Signature = loo_Signer.MacStringENC(loo_StringToSign.GetAsString())
if loo_Signer.LastMethodSuccess <> 1 then
    Write-Debug "Could not sign request."
    destroy loo_StringCompare
    destroy loo_Credentials
    destroy loo_Http
    destroy loo_Endpoint
    destroy loo_Response
    destroy loo_Signer
    destroy loo_Now
    destroy loo_Timestamp
    destroy loo_Canonical
    destroy loo_CanonicalHeaders
    destroy loo_SignedHeaders
    destroy loo_Scope
    destroy loo_StringToSign
    destroy loo_SigningKey
    destroy loo_Authorization
    destroy loo_Url
    destroy loo_Query
    destroy loo_Number
    destroy loo_Host
    destroy loo_Uri
    destroy loo_Xml
    return
end if

loo_Authorization.Clear()
loo_Authorization.Append("AWS4-HMAC-SHA256 Credential=")
loo_Authorization.Append(loo_Credentials.StringOf("access_key"))
loo_Authorization.Append("/")
loo_Authorization.Append(loo_Scope.GetAsString())
loo_Authorization.Append(", SignedHeaders=")
loo_Authorization.Append(loo_SignedHeaders.GetAsString())
loo_Authorization.Append(", Signature=")
loo_Authorization.Append(ls_Signature)
loo_Http.SetRequestHeader("Authorization",loo_Authorization.GetAsString())
loo_Url.SetString("https://")
loo_Url.Append(loo_Host.GetAsString())
loo_Url.Append(loo_Uri.GetAsString())
if loo_Query.Length > 0 then
    loo_Url.Append("?")
    loo_Url.Append(loo_Query.GetAsString())
end if

li_Success = loo_Http.HttpNoBody("HEAD",loo_Url.GetAsString(),loo_Response)
if (li_Success <> 1) OR (loo_Response.StatusCode <> 200) then
    Write-Debug "Request failed or returned unexpected HTTP status: " + string(loo_Response.StatusCode)
    //  Preserve progress. Inspect full diagnostics privately; do not log secrets.
    destroy loo_StringCompare
    destroy loo_Credentials
    destroy loo_Http
    destroy loo_Endpoint
    destroy loo_Response
    destroy loo_Signer
    destroy loo_Now
    destroy loo_Timestamp
    destroy loo_Canonical
    destroy loo_CanonicalHeaders
    destroy loo_SignedHeaders
    destroy loo_Scope
    destroy loo_StringToSign
    destroy loo_SigningKey
    destroy loo_Authorization
    destroy loo_Url
    destroy loo_Query
    destroy loo_Number
    destroy loo_Host
    destroy loo_Uri
    destroy loo_Xml
    return
end if

ls_Value = loo_Response.GetHeaderField("ETag")
if loo_Response.LastMethodSuccess = 1 then
    Write-Debug "ETag: " + ls_Value
end if

ls_Value = loo_Response.GetHeaderField("Content-Length")
if loo_Response.LastMethodSuccess = 1 then
    Write-Debug "Content-Length: " + ls_Value
end if

ls_Value = loo_Response.GetHeaderField("x-amz-version-id")
if loo_Response.LastMethodSuccess = 1 then
    Write-Debug "x-amz-version-id: " + ls_Value
end if

ls_Value = loo_Response.GetHeaderField("x-amz-checksum-type")
if loo_Response.LastMethodSuccess = 1 then
    Write-Debug "x-amz-checksum-type: " + ls_Value
end if

ls_Value = loo_Response.GetHeaderField("x-amz-checksum-sha256")
if loo_Response.LastMethodSuccess = 1 then
    Write-Debug "x-amz-checksum-sha256: " + ls_Value
end if

ls_Value = loo_Response.GetHeaderField("x-amz-checksum-crc32")
if loo_Response.LastMethodSuccess = 1 then
    Write-Debug "x-amz-checksum-crc32: " + ls_Value
end if

ls_Value = loo_Response.GetHeaderField("x-amz-checksum-crc32c")
if loo_Response.LastMethodSuccess = 1 then
    Write-Debug "x-amz-checksum-crc32c: " + ls_Value
end if

ls_Value = loo_Response.GetHeaderField("x-amz-checksum-crc64nvme")
if loo_Response.LastMethodSuccess = 1 then
    Write-Debug "x-amz-checksum-crc64nvme: " + ls_Value
end if

ls_Value = loo_Response.GetHeaderField("x-amz-server-side-encryption")
if loo_Response.LastMethodSuccess = 1 then
    Write-Debug "x-amz-server-side-encryption: " + ls_Value
end if

Write-Debug "Checksum metadata read complete."


destroy loo_StringCompare
destroy loo_Credentials
destroy loo_Http
destroy loo_Endpoint
destroy loo_Response
destroy loo_Signer
destroy loo_Now
destroy loo_Timestamp
destroy loo_Canonical
destroy loo_CanonicalHeaders
destroy loo_SignedHeaders
destroy loo_Scope
destroy loo_StringToSign
destroy loo_SigningKey
destroy loo_Authorization
destroy loo_Url
destroy loo_Query
destroy loo_Number
destroy loo_Host
destroy loo_Uri
destroy loo_Xml