Class | Hookout::Utils |
In: |
lib/hookout/reversehttp_connector.rb
|
Parent: | Object |
# File lib/hookout/reversehttp_connector.rb, line 177 def initialize @current_http = nil @current_thread = nil end
# File lib/hookout/reversehttp_connector.rb, line 215 def self.post_data(url, data) parts = URI.parse(url) req = Net::HTTP::Post.new(parts.path) req.body = data req.content_type = 'message/http' Net::HTTP.start(parts.host, parts.port) {|http| http.request(req) } end
# File lib/hookout/reversehttp_connector.rb, line 195 def abort @current_http.finish if @current_http @current_thread.raise ConnectorAbortException.new if @current_thread end
# File lib/hookout/reversehttp_connector.rb, line 200 def execute_request(parts, req) begin Net::HTTP.start(parts.host, parts.port) {|http| @current_http = http @current_thread = Thread.current http.request(req) } rescue ConnectorAbortException return nil ensure @current_http = nil @current_thread = nil end end
# File lib/hookout/reversehttp_connector.rb, line 182 def get(url) parts = URI.parse(url) req = Net::HTTP::Get.new(parts.path) execute_request(parts, req) end