From f2eba3c329e3b4cef847ef08563bfa3c4bf6a9c8 Mon Sep 17 00:00:00 2001 From: Isaac Sanders Date: Sun, 15 Apr 2012 08:31:36 -0500 Subject: [PATCH] Added HTTP method PATCH. --- lib/net/http.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lib/net/http.rb b/lib/net/http.rb index d5395767e8958b..d2f33d9d2e173c 100644 --- a/lib/net/http.rb +++ b/lib/net/http.rb @@ -200,6 +200,7 @@ class HTTPHeaderSyntaxError < StandardError; end # Net::HTTP::Head # Net::HTTP::Post # Net::HTTP::Put + # Net::HTTP::Patch # Net::HTTP::Proppatch # Net::HTTP::Lock # Net::HTTP::Unlock @@ -918,6 +919,12 @@ def put(path, data, initheader = nil) #:nodoc: res end + def patch(path, data, initheader = nil) #:nodoc: + res = request(Patch.new(path, initheader), data) + res.value unless @newimpl + res + end + # Sends a PROPPATCH request to the +path+ and gets a response, # as an HTTPResponse object. def proppatch(path, body, initheader = nil) @@ -1738,6 +1745,12 @@ class Put < HTTPRequest RESPONSE_HAS_BODY = true end + class Patch < HTTPRequest + METHOD = 'PATCH' + REQUEST_HAS_BODY = true + RESPONSE_HAS_BODY = true + end + class Delete < HTTPRequest METHOD = 'DELETE' REQUEST_HAS_BODY = false