The Web Dev Zone is brought to you in partnership with Mendix. Discover how IT departments looking for ways to keep up with demand for business apps has caused a new breed of developers to surface - the Rapid Application Developer.
Making HTTPS requests seems oddly difficult. Why can't an HTTP library just figure things out for me like curl does? It mostly can...
You have to breakup the URL into a host, port, and path, then make a request with use_ssl.
$ irb require 'net/http' uri = URI::parse("https://artsy.net/api/v1/system/up") Net::HTTP.start uri.host, uri.port, use_ssl: (uri.scheme == "https") do |http| request = Net::HTTP::Get.new(uri.path) response = http.request request puts response.body end
A little simpler. Superagent, also known as “ajax with less suck,” can take care of everything.
$ npm install -g superagent $ coffee http = require('superagent') http.get('https://artsy.net/api/v1/system/up').end((err, res) -> console.log res.body)