Skip to content

Commit 8e09c9d

Browse files
authored
Merge pull request #10 from clee-r7/add-http-put-request
Add HTTP PUT request method
2 parents 89a44e8 + 4989e94 commit 8e09c9d

File tree

1 file changed

+16
-0
lines changed
  • lib/metasploit/framework/data_service/remote/http

1 file changed

+16
-0
lines changed

lib/metasploit/framework/data_service/remote/http/core.rb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ class RemoteHTTPDataService
1919
GET_REQUEST = 'GET'
2020
POST_REQUEST = 'POST'
2121
DELETE_REQUEST = 'DELETE'
22+
PUT_REQUEST = 'PUT'
2223

2324
#
2425
# @param [String] endpoint A valid http or https URL. Cannot be nil
@@ -82,6 +83,19 @@ def delete_data(path, data_hash, query = nil)
8283
make_request(DELETE_REQUEST, path, data_hash, query)
8384
end
8485

86+
#
87+
# Send PUT request to store data for the specified resource at the HTTP endpoint
88+
#
89+
# @param path - The URI path to send the request
90+
# @param data_hash - A hash representation of the object to be stored. Cannot be nil or empty.
91+
# @param query - A hash representation of the URI query data. Key-value pairs will be URL-encoded.
92+
#
93+
# @return A wrapped response (ResponseWrapper), see below.
94+
#
95+
def put_data(path, data_hash, query = nil)
96+
make_request(PUT_REQUEST, path, data_hash, query)
97+
end
98+
8599
#
86100
# Make the specified request_type
87101
#
@@ -106,6 +120,8 @@ def make_request(request_type, path, data_hash = nil, query = nil)
106120
request = Net::HTTP::Post.new(uri.request_uri)
107121
when DELETE_REQUEST
108122
request = Net::HTTP::Delete.new(uri.request_uri)
123+
when PUT_REQUEST
124+
request = Net::HTTP::Put.new(uri.request_uri)
109125
else
110126
raise Exception, 'A request_type must be specified'
111127
end

0 commit comments

Comments
 (0)