Xojo Plugin
Xojo Plugin
Get a REST Response Header by Name
See more REST Examples
Demonstrates Rest.ResponseHdrByName, which returns the value of a response header field by name. Header field names are case-insensitive.
Background. Response headers are available after ReadResponseHeader has read the status line and headers. Lookup by name is convenient when a specific header, such as Content-Type, is needed.
Chilkat Xojo Plugin Downloads
Dim success As Boolean
success = False
Dim rest As New Chilkat.Rest
Dim bTls As Boolean
bTls = True
Dim bAutoReconnect As Boolean
bAutoReconnect = True
success = rest.Connect("example.com",443,bTls,bAutoReconnect)
If (success = False) Then
System.DebugLog(rest.LastErrorText)
Return
End If
success = rest.SendReqNoBody("GET","/api/items/123")
If (success = False) Then
System.DebugLog(rest.LastErrorText)
Return
End If
Dim statusCode As Int32
statusCode = rest.ReadResponseHeader()
If (statusCode < 0) Then
System.DebugLog(rest.LastErrorText)
Return
End If
// Return the value of a response header field by name. Header field names are case-insensitive.
Dim contentType As String
contentType = rest.ResponseHdrByName("Content-Type")
If (rest.LastMethodSuccess = False) Then
System.DebugLog(rest.LastErrorText)
Return
End If
System.DebugLog("Content-Type: " + contentType)