From d4ac54bbd6767c5997dcca14cb365f05a7348af1 Mon Sep 17 00:00:00 2001 From: Syl Turner Date: Tue, 12 Jul 2011 11:30:35 -0400 Subject: [PATCH] Added a check to see if the Patch class already exists in Net::HTTP (then we don't need this monkey patch) --- lib/restclient/net_http_ext.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/restclient/net_http_ext.rb b/lib/restclient/net_http_ext.rb index b40dbbc9..ee40e9e0 100644 --- a/lib/restclient/net_http_ext.rb +++ b/lib/restclient/net_http_ext.rb @@ -1,7 +1,8 @@ module Net - class HTTP + class HTTP - # Adding the patch method (rest-client issue: https://github.com/archiloque/rest-client/issues/79) + # Adding the patch method if it doesn't exist (rest-client issue: https://github.com/archiloque/rest-client/issues/79) + if !defined?(Net::HTTP::Patch) # Code taken from this commit: https://github.com/ruby/ruby/commit/ab70e53ac3b5102d4ecbe8f38d4f76afad29d37d#lib/net/http.rb class Protocol # Sends a PATCH request to the +path+ and gets a response, @@ -31,6 +32,7 @@ class Patch < HTTPRequest REQUEST_HAS_BODY = true RESPONSE_HAS_BODY = true end + end # # Replace the request method in Net::HTTP to sniff the body type