End of Life Ruby 3.1 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
instance method
Net::HTTP#request_post
request_post(path, data, initheader = nil) { |response| ... }
lib/net/http.rb
View on GitHub ↗
# File tmp/rubies/ruby-3.1.3/lib/net/http.rb, line 1517
def request_post(path, data, initheader = nil, &block) # :yield: +response+
request Post.new(path, initheader), data, &block
end
Sends a POST request to the path.
Returns the response as a Net::HTTPResponse object.
When called with a block, the block is passed an HTTPResponse object. The body of that response will not have been read yet; the block can process it using HTTPResponse#read_body, if desired.
Returns the response.
This method never raises Net::* exceptions.
Example
# example response = http.request_post('/cgi-bin/nice.rb', 'datadatadata...') p response.status puts response.body # body is already read in this case # using block http.request_post('/cgi-bin/nice.rb', 'datadatadata...') {|response| p response.status p response['content-type'] response.read_body do |str| # read body now print str end }
See also
#request_head
#response_body_encoding=
#request_get
#send_entity
also in
4.1 · 4.0 · 3.4 · 3.3 · 3.2 · 3.0