Ruby
Ruby
Inspect HTTP Request Header
Demonstrates theLastHeader property.
Chilkat Ruby Downloads
require 'chilkat'
success = false
http = Chilkat::CkHttp.new()
url = "https://chilkatsoft.com/echo_request_body.asp"
json = "{\"greeting\":\"Hello World\"}"
# Send a POST with the JSON in the HTTP request body.
resp = Chilkat::CkHttpResponse.new()
success = http.HttpStr("POST",url,json,"utf-8","application/json",resp)
if (success == false)
print http.lastErrorText() + "\n";
exit
end
# Examine the HTTP request header we just sent.
print http.lastHeader() + "\n";
# Output:
# POST /echo_request_body.asp HTTP/1.1
# Host: chilkatsoft.com
# Accept: */*
# Accept-Encoding: gzip
# Content-Type: application/json
# Content-Length: 26