summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThom May <thom@may.lt>2017-07-24 10:04:32 +0100
committerGitHub <noreply@github.com>2017-07-24 10:04:32 +0100
commited5ee65760bd2dd5e47b0b1613a8e455a3082b1a (patch)
tree1c09de3d72d23c8879b8f8807fba83b7c3514397
parent20e69231e1bdb153529e19425599b145dd800ffd (diff)
parent788bbff36108a6952da19538150e685ae45694d1 (diff)
downloadchef-ed5ee65760bd2dd5e47b0b1613a8e455a3082b1a.tar.gz
Merge pull request #6131 from jamesbroadhead/add_HTTP_PATCH
Add support for HTTP PATCH requests
-rw-r--r--lib/chef/http/http_request.rb3
-rw-r--r--lib/chef/provider/http_request.rb14
-rw-r--r--lib/chef/resource/http_request.rb2
3 files changed, 18 insertions, 1 deletions
diff --git a/lib/chef/http/http_request.rb b/lib/chef/http/http_request.rb
index 20c46aaa8d..7fc1acb889 100644
--- a/lib/chef/http/http_request.rb
+++ b/lib/chef/http/http_request.rb
@@ -49,6 +49,7 @@ class Chef
ENCODING_GZIP_DEFLATE = "gzip;q=1.0,deflate;q=0.6,identity;q=0.3".freeze
GET = "get".freeze
+ PATCH = "patch".freeze
PUT = "put".freeze
POST = "post".freeze
DELETE = "delete".freeze
@@ -161,6 +162,8 @@ class Chef
Net::HTTP::Post.new(req_path, headers)
when PUT
Net::HTTP::Put.new(req_path, headers)
+ when PATCH
+ Net::HTTP::Patch.new(req_path, headers)
when DELETE
Net::HTTP::Delete.new(req_path, headers)
when HEAD
diff --git a/lib/chef/provider/http_request.rb b/lib/chef/provider/http_request.rb
index 8370c2375c..cafdc1e007 100644
--- a/lib/chef/provider/http_request.rb
+++ b/lib/chef/provider/http_request.rb
@@ -62,6 +62,20 @@ class Chef
end
end
+ # Send a PATCH request to new_resource.url, with the message as the payload
+ def action_patch
+ converge_by("#{new_resource} PATCH to #{new_resource.url}") do
+ message = check_message(new_resource.message)
+ body = @http.patch(
+ "#{new_resource.url}",
+ message,
+ new_resource.headers
+ )
+ Chef::Log.info("#{new_resource} PATCH to #{new_resource.url} successful")
+ Chef::Log.debug("#{new_resource} PATCH request response: #{body}")
+ end
+ end
+
# Send a PUT request to new_resource.url, with the message as the payload
def action_put
converge_by("#{new_resource} PUT to #{new_resource.url}") do
diff --git a/lib/chef/resource/http_request.rb b/lib/chef/resource/http_request.rb
index fcc48470bc..9fac3562f3 100644
--- a/lib/chef/resource/http_request.rb
+++ b/lib/chef/resource/http_request.rb
@@ -27,7 +27,7 @@ class Chef
identity_attr :url
default_action :get
- allowed_actions :get, :put, :post, :delete, :head, :options
+ allowed_actions :get, :patch, :put, :post, :delete, :head, :options
def initialize(name, run_context = nil)
super