Index: lib/net/http.rb =================================================================== --- lib/net/http.rb (revision 27994) +++ lib/net/http.rb (working copy) @@ -966,17 +966,14 @@ # "application/x-www-form-urlencoded" by default. # def post(path, data, initheader = nil, dest = nil, &block) # :yield: +body_segment+ - res = nil - request(Post.new(path, initheader), data) {|r| - r.read_body dest, &block - res = r - } - unless @newimpl - res.value - return res, res.body - end - res + send_entity(path, data, initheader, dest, Post, &block) end + + # Sends a PATCH request to the +path+ and gets a response, + # as an HTTPResponse object. + def patch(path, data, initheader = nil, dest = nil, &block) # :yield: +body_segment+ + send_entity(path, data, initheader, dest, Patch, &block) + end def put(path, data, initheader = nil) #:nodoc: res = request(Put.new(path, initheader), data) @@ -1176,6 +1173,21 @@ private + # Executes a request which uses a representation + # and returns its body. + def send_entity(path, data, initheader, dest, type, &block) + res = nil + request(type.new(path, initheader), data) {|r| + r.read_body dest, &block + res = r + } + unless @newimpl + res.value + return res, res.body + end + res + end + def transport_request(req) begin_transport req req.exec @socket, @curr_http_version, edit_path(req.path) @@ -1832,6 +1844,16 @@ end # + # PATCH method --- RFC5789 + # + + class Patch < HTTPRequest + METHOD = 'PATCH' + REQUEST_HAS_BODY = true + RESPONSE_HAS_BODY = true + end + + # # WebDAV methods --- RFC2518 #