Skip to content
Browse files

adds proper support for https to make gists

  • Loading branch information...
1 parent 4380518 commit 42881cb5ed1d423a4f33844569c61e55988a9cef Matt Heitzenroder committed
Showing with 3,520 additions and 3 deletions.
  1. +3,509 −0 Support/lib/cacert.pem
  2. +11 −3 Support/lib/gist.rb
View
3,509 Support/lib/cacert.pem
3,509 additions, 0 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View
14 Support/lib/gist.rb
@@ -3,6 +3,8 @@
require 'open-uri'
require 'net/http'
+require 'net/https'
+
module Gist
extend self
@@ -25,12 +27,18 @@ def add_file(name, content)
def send(private_gist)
load_files
url = URI.parse('https://gist.github.com/gists')
- req = Net::HTTP.post_form(url, data(private_gist))
- case req
+ req = Net::HTTP::Post.new(url.path)
+ req.set_form_data(data(private_gist))
+ https = Net::HTTP.new(url.host, url.port)
+ https.use_ssl = true
+ https.verify_mode = OpenSSL::SSL::VERIFY_PEER
+ https.ca_file = File.join(File.dirname(__FILE__), "cacert.pem")
+ res = https.start {|http| http.request(req) }
+ case res
when Net::HTTPBadRequest
print "Ewww, not your fault, but something bad happened. No gist created."
when Net::HTTPFound
- url = copy req['Location']
+ url = copy res['Location']
print "Created gist at #{url}. URL copied to clipboard."
end
clear

0 comments on commit 42881cb

Please sign in to comment.
Something went wrong with that request. Please try again.