Class: Clockwork::HTTP
- Inherits:
-
Object
- Object
- Clockwork::HTTP
- Defined in:
- lib/clockwork/http.rb
Overview
Wrapper around NET/HTTP
Class Method Summary collapse
-
.post(url, data = '', use_ssl = true) ⇒ string
Build a HTTP POST request.
Class Method Details
.post(url, data = '', use_ssl = true) ⇒ string
Build a HTTP POST request.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/clockwork/http.rb', line 12 def self.post url, data = '', use_ssl = true if use_ssl uri = URI.parse "https://#{url}" req = Net::HTTP::Post.new( uri.path ) socket = Net::HTTP.new( uri.host, uri.port ) socket.use_ssl = true socket.verify_mode = OpenSSL::SSL::VERIFY_PEER else uri = URI.parse "http://#{url}" req = Net::HTTP::Post.new( uri.path ) socket = Net::HTTP.new( uri.host, uri.port ) end req.content_type = "text/xml" req.body = data req.add_field "User-Agent", "Clockwork Ruby Wrapper/#{Clockwork::VERSION}" response = socket.start do |http| http.request( req ) end response end |