Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →
instance method
Net::HTTPSession#patch
patch(path, data, initheader = nil) {|res| ... }
lib/net/http.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.1.0-preview1/lib/net/http.rb, line 2104
def patch(path, data, initheader = nil, dest = nil, &block) # :yield: +body_segment+
send_entity(path, data, initheader, dest, Patch, &block)
end
Sends a PATCH request to the server; returns an instance of a subclass of Net::HTTPResponse.
The request is based on the Net::HTTP::Patch object created from string path, string data, and initial headers hash initheader.
With a block given, calls the block with the response body:
Example
data = '{"userId": 1, "id": 1, "title": "delectus aut autem", "completed": false}' http = Net::HTTP.new(hostname) http.patch('/todos/1', data) do |res| p res end # => #<Net::HTTPOK 200 OK readbody=true>
Output:
Example
"{\n \"userId\": 1,\n \"id\": 1,\n \"title\": \"delectus aut autem\",\n \"completed\": false,\n \"{\\\"userId\\\": 1, \\\"id\\\": 1, \\\"title\\\": \\\"delectus aut autem\\\", \\\"completed\\\": false}\": \"\"\n}"
With no block given, simply returns the response object:
Example
http.patch('/todos/1', data) # => #<Net::HTTPCreated 201 Created readbody=true>