DataFlex
DataFlex
HTTP Response Inspection
See more HTTP Examples
Demonstrates how to inspect the HTTP response, including the status code, status text, and response headers, for Chilkat methods that don't use anHttpResponse object.
Chilkat DataFlex Downloads
Use ChilkatAx-win32.pkg
Procedure Test
Handle hoHttp
String sJsonText
Handle hoMime
Boolean iSuccess
Integer iNumHeaders
Integer i
String sTemp1
Integer iTemp1
Get Create (RefClass(cComChilkatHttp)) To hoHttp
If (Not(IsComObjectCreated(hoHttp))) Begin
Send CreateComObject of hoHttp
End
// Returns the contents of the response body.
Get ComQuickGetStr Of hoHttp "https://chilkatsoft.com/helloWorld.json" To sJsonText
// Examine the response status code.
Get ComLastStatus Of hoHttp To iTemp1
Showln "response status code: " iTemp1
// Examine the response status text
Get ComLastStatusText Of hoHttp To sTemp1
Showln "response status text: " sTemp1
// Examine the full response header.
Showln "response header:"
Get ComLastResponseHeader Of hoHttp To sTemp1
Showln sTemp1
Showln "----"
// Examine the response content-type
Get ComLastContentType Of hoHttp To sTemp1
Showln "LastContentType = " sTemp1
// Examine the response last-mod date
Get ComLastModDate Of hoHttp To sTemp1
Showln "LastModDate = " sTemp1
// Load the response header into a Chilkat MIME object to access its fields individually.
Get Create (RefClass(cComChilkatMime)) To hoMime
If (Not(IsComObjectCreated(hoMime))) Begin
Send CreateComObject of hoMime
End
Get ComLastResponseHeader Of hoHttp To sTemp1
Get ComLoadMime Of hoMime sTemp1 To iSuccess
Get ComNumHeaderFields Of hoMime To iNumHeaders
Move 0 To i
Showln "---- MIME Headers ----"
While (i < iNumHeaders)
Get ComGetHeaderFieldName Of hoMime i To sTemp1
Showln "name: " sTemp1
Get ComGetHeaderFieldValue Of hoMime i To sTemp1
Showln "value: " sTemp1
Move (i + 1) To i
Loop
Showln "----"
// Get a header field value by name:
Get ComGetHeaderField Of hoMime "ETag" To sTemp1
Showln "ETag: " sTemp1
// Output:
// response status code: 200
// response status text: OK
// response header:
// Content-Type: application/json
// Last-Modified: Sun, 20 Aug 2023 11:36:27 GMT
// Accept-Ranges: bytes
// ETag: "34c27f8e5ad3d91:0"
// Server: Microsoft-IIS/10.0
// X-Powered-By: ASP.NET
// Date: Sat, 30 Aug 2025 14:38:13 GMT
// Content-Length: 22
// ----
// LastContentType = application/json
// LastModDate = 2023-08-20
// ---- MIME Headers ----
// name: Content-Type
// value: application/json
// name: Last-Modified
// value: Sun, 20 Aug 2023 11:36:27 GMT
// name: Accept-Ranges
// value: bytes
// name: ETag
// value: "34c27f8e5ad3d91:0"
// name: Server
// value: Microsoft-IIS/10.0
// name: X-Powered-By
// value: ASP.NET
// name: Date
// value: Sat, 30 Aug 2025 14:38:13 GMT
// name: Content-Length
// value: 22
// ----
// ETag: "34c27f8e5ad3d91:0"
End_Procedure