(VBScript) Inspect HTTP Request Header
Demonstrates the LastHeader property.
Dim fso, outFile
Set fso = CreateObject("Scripting.FileSystemObject")
'Create a Unicode (utf-16) output text file.
Set outFile = fso.CreateTextFile("output.txt", True, True)
success = 0
set http = CreateObject("Chilkat.Http")
url = "https://chilkatsoft.com/echo_request_body.asp"
json = "{""greeting"":""Hello World""}"
' Send a POST with the JSON in the HTTP request body.
set resp = CreateObject("Chilkat.HttpResponse")
success = http.HttpStr("POST",url,json,"utf-8","application/json",resp)
If (success = 0) Then
outFile.WriteLine(http.LastErrorText)
WScript.Quit
End If
' Examine the HTTP request header we just sent.
outFile.WriteLine(http.LastHeader)
' Output:
' POST /echo_request_body.asp HTTP/1.1
' Host: chilkatsoft.com
' Accept: */*
' Accept-Encoding: gzip
' Content-Type: application/json
' Content-Length: 26
outFile.Close
|