Module: Releaseable::HTTP
- Defined in:
- lib/releaseable/http.rb
Class Method Summary collapse
Class Method Details
.get(address, user, pass, query) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/releaseable/http.rb', line 46 def self.get address, user, pass, query uri = URI("#{address}?" + query.map { |k, v| "#{k}=#{URI.encode(v.to_s)}" }.join('&')) p uri.request_uri server = Net::HTTP.new(uri.host, uri.port) #server.use_ssl = (uri.scheme == 'https') #server.verify_mode = OpenSSL::SSL::VERIFY_NONE if server.use_ssl? server.start do |http| req = Net::HTTP::Get.new(uri.request_uri) req.basic_auth user, pass http.request(req) end end |
.post(address, data) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/releaseable/http.rb', line 25 def self.post address, data uri = URI(address) p uri.request_uri server = Net::HTTP.new(uri.host, uri.port) server.use_ssl = (uri.scheme == 'https') server.verify_mode = OpenSSL::SSL::VERIFY_NONE if server.use_ssl? server.start do |http| req = Net::HTTP::Post.new(uri.path) case data when Hash req.form_data = data when Array req.body = data req.content_type = 'multipart/form-data' end http.request(req) end end |