Sample code for 30+ languages & platforms
Ruby

Example: Http.QuickGetStr method

Demonstrates the QuickGetStr method.

Chilkat Ruby Downloads

Ruby
require 'chilkat'

http = Chilkat::CkHttp.new()

# Keep the response body if there's an error.
http.put_KeepResponseBody(true)

# Send the HTTP GET and return the content in a string.
str = http.quickGetStr("https://www.chilkatsoft.com/helloWorld.json")
if (http.get_LastMethodSuccess() == false)
    if (http.get_LastStatus() == 0)
        # Communications error.  We did not get a response.
        print http.lastErrorText() + "\n";
    else
        print "Response status code: " + http.get_LastStatus().to_s() + "\n";
        print "Response body error text:" + "\n";
        print http.lastResponseBody() + "\n";
    end

    exit
end

print str + "\n";
print "Success" + "\n";