lib/auger/plugin/http.rb in auger-1.4.3 vs lib/auger/plugin/http.rb in auger-1.4.4

- old
+ new

@@ -42,10 +42,14 @@ def post(url, &block) @requests << Auger::HttpPost.load(url, &block) end + def propfind(url, &block) + @requests << Auger::HttpPropfind.load(url, &block) + end + def open(host, options) http = Net::HTTP.new(host, options[:port]) http.use_ssl = options[:ssl] http.verify_mode = OpenSSL::SSL::VERIFY_NONE if options[:insecure] http.open_timeout = options[:timeout] @@ -59,11 +63,11 @@ end end class HttpRequest < Auger::Request - attr_accessor :method, :headers, :user, :password, :data + attr_accessor :method, :headers, :user, :password, :data, :body alias_method :url, :arg def initialize(url) @method ||= :get # default @headers = {} @@ -73,10 +77,14 @@ def data(hash) @data = hash end + def body(string) + @body = string + end + def header(h) key, value = h.split /\s*:\s*/ @headers[key] = value end @@ -91,10 +99,11 @@ def run(http, url) request = Net::HTTP::const_get(@method.capitalize).new(url) # e.g. Net::HTTP::Get request.basic_auth(@user, @password || '') if @user @headers.each { |k,v| request[k] = v } request.set_form_data(@data) + request.body = @body http.request(request) end end @@ -106,9 +115,16 @@ end class HttpPost < Auger::HttpRequest def initialize(url) @method = :post + super + end + end + + class HttpPropfind < Auger::HttpRequest + def initialize(url) + @method = :propfind super end end end