Skip to content

Instantly share code, notes, and snippets.

@mrsimo
Created July 4, 2012 07:46
Show Gist options
  • Save mrsimo/3045958 to your computer and use it in GitHub Desktop.
Save mrsimo/3045958 to your computer and use it in GitHub Desktop.
HTTPS request with Net::HTTP and basic http auth
site = URI("https://some.domain.net/path?event_id=#{event.id}")
http = Net::HTTP.new(site.host, site.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE if Rails.env.development?
http.open_timeout = 1
http.read_timeout = 1
req = Net::HTTP::Get.new("#{site.path}?#{site.query}")
req.basic_auth 'user', 'pass'
response = http.request(req)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment