DataFlex
DataFlex
Inspect HTTP Request Header
Demonstrates theLastHeader property.
Chilkat DataFlex Downloads
Use ChilkatAx-win32.pkg
Procedure Test
Boolean iSuccess
Handle hoHttp
String sUrl
String sJson
Variant vResp
Handle hoResp
String sTemp1
Move False To iSuccess
Get Create (RefClass(cComChilkatHttp)) To hoHttp
If (Not(IsComObjectCreated(hoHttp))) Begin
Send CreateComObject of hoHttp
End
Move "https://chilkatsoft.com/echo_request_body.asp" To sUrl
Move '{"greeting":"Hello World"}' To sJson
// Send a POST with the JSON in the HTTP request body.
Get Create (RefClass(cComChilkatHttpResponse)) To hoResp
If (Not(IsComObjectCreated(hoResp))) Begin
Send CreateComObject of hoResp
End
Get pvComObject of hoResp to vResp
Get ComHttpStr Of hoHttp "POST" sUrl sJson "utf-8" "application/json" vResp To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoHttp To sTemp1
Showln sTemp1
Procedure_Return
End
// Examine the HTTP request header we just sent.
Get ComLastHeader Of hoHttp To sTemp1
Showln sTemp1
// Output:
// POST /echo_request_body.asp HTTP/1.1
// Host: chilkatsoft.com
// Accept: */*
// Accept-Encoding: gzip
// Content-Type: application/json
// Content-Length: 26
End_Procedure