PowerBuilder
PowerBuilder
Get Response Header for Method that does not Return HttpResponse Object
Demonstrates how to get the response header and individual response header fields for a method that does not return an HTTP response object. (If a method returns an HHTTP response object, then the response header information should be obtained from the response object.)Chilkat PowerBuilder Downloads
integer li_rc
integer li_Success
oleobject loo_Http
string ls_StrHtml
oleobject loo_Mime
li_Success = 0
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
loo_Http = create oleobject
li_rc = loo_Http.ConnectToNewObject("Chilkat.Http")
if li_rc < 0 then
destroy loo_Http
MessageBox("Error","Connecting to COM object failed")
return
end if
ls_StrHtml = loo_Http.QuickGetStr("https://www.duckduckgo.com/")
if loo_Http.LastMethodSuccess = 0 then
Write-Debug loo_Http.LastErrorText
destroy loo_Http
return
end if
Write-Debug loo_Http.LastResponseHeader
// Here's a sample HTTP response header:
// Server: nginx
// Date: Wed, 30 Sep 2020 13:13:02 GMT
// Content-Type: text/html; charset=UTF-8
// Transfer-Encoding: chunked
// Connection: keep-alive
// Vary: Accept-Encoding
// ETag: W/"5f7371f4-1683"
// Strict-Transport-Security: max-age=31536000
// X-Frame-Options: SAMEORIGIN
// Content-Security-Policy: default-src https: blob: data: 'unsafe-inline' 'unsafe-eval'; frame-ancestors 'self'
// X-XSS-Protection: 1;mode=block
// X-Content-Type-Options: nosniff
// Referrer-Policy: origin
// Expect-CT: max-age=0
// Expires: Wed, 30 Sep 2020 13:13:01 GMT
// Cache-Control: no-cache
// Content-Encoding: gzip
// We can load it into a Chilkat MIME object to get header field values:
loo_Mime = create oleobject
li_rc = loo_Mime.ConnectToNewObject("Chilkat.Mime")
li_Success = loo_Mime.LoadMime(loo_Http.LastResponseHeader)
if li_Success = 0 then
Write-Debug loo_Mime.LastErrorText
destroy loo_Http
destroy loo_Mime
return
end if
// Get MIME header field values using Chilkat MIME...
Write-Debug "----"
Write-Debug "ETag: " + loo_Mime.GetHeaderField("ETag")
destroy loo_Http
destroy loo_Mime