lib/rufus/verbs/endpoint.rb in rufus-verbs-0.4 vs lib/rufus/verbs/endpoint.rb in rufus-verbs-0.5

- old
+ new

@@ -109,10 +109,20 @@ def delete (*args) request :delete, args end + def head (*args) + + request :head, args + end + + def options (*args) + + request :options, args + end + # # This is the method called by the module methods verbs. # # For example, # @@ -177,10 +187,12 @@ # used in case of :digest_authentication # will have no effect else res = handle_response method, res, opts + return parse_options(res) if method == :options + return res.body if o(opts, :body) res end @@ -521,9 +533,30 @@ end decompress res res + end + + # + # Returns an array of symbols, like for example + # + # [ :get, :post ] + # + # obtained by parsing the 'Allow' response header. + # + # This method is used to provide the result of an OPTIONS + # HTTP method. + # + def parse_options (res) + + s = res['Allow'] + + return [] unless s + + s.split(",").collect do |m| + m.strip.downcase.to_sym + end end # # Returns true if the current request has authentication # going on.