Skip to content

Commit

Permalink
How are you?
Browse files Browse the repository at this point in the history
  • Loading branch information
ujihisa committed Aug 16, 2009
1 parent a0ab6c1 commit d27f12e
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
File renamed without changes.
34 changes: 34 additions & 0 deletions net-https-wrapper.rb
@@ -0,0 +1,34 @@
require 'net/https'

class Net::HTTP
def self.post(uri, data, header)
__post_or_put__(:post, uri, data, header)
end

def self.put(uri, data, header)
__post_or_put__(:put, uri, data, header)
end

def self.__post_or_put__(method, uri, data, header)
uri = URI.parse(uri)
i = new(uri.host, uri.port)
unless uri.port == 80
i.use_ssl = true
i.verify_mode = OpenSSL::SSL::VERIFY_NONE
end
i.__send__(method, uri.path, data, header)
end
end

# sample code
# a = Net::HTTP.post(
# 'https://www.google.com/accounts/ClientLogin',
# {
# 'Email' => email,
# 'Passwd' => pass,
# 'service' => 'blogger',
# 'accountType' => 'HOSTED_OR_GOOGLE',
# 'source' => 'ujihisa-bloggervim-1'
# }.map {|i, j| "#{i}=#{j}" }.join('&'),
# {'Content-Type' => 'application/x-www-form-urlencoded'})
# a.body.lines.to_a.maph {|i| i.split('=') }['Auth'].chomp

0 comments on commit d27f12e

Please sign in to comment.