Class: Net::HTTP::Post
- Inherits:
-
Net::HTTPRequest
- Object
- Net::HTTPGenericRequest
- Net::HTTPRequest
- Net::HTTP::Post
- Defined in:
- lib/net/http/requests.rb
Overview
Class for representing HTTP method POST:
require 'net/http'
uri = URI('http://example.com')
hostname = uri.hostname # => "example.com"
uri.path = '/posts'
req = Net::HTTP::Post.new(uri) # => #<Net::HTTP::Post POST>
req.body = '{"title": "foo","body": "bar","userId": 1}'
req.content_type = 'application/json'
res = Net::HTTP.start(hostname) do |http|
http.request(req)
end
See Request Headers.
Properties:
- Request body: yes.
- Response body: yes.
- Safe: no.
- Idempotent: no.
- Cacheable: yes.
Related:
- Net::HTTP.post: sends
POSTrequest, returns response object. - Net::HTTP#post: sends
POSTrequest, returns response object.
Constant Summary collapse
- METHOD =
'POST'- REQUEST_HAS_BODY =
true- RESPONSE_HAS_BODY =
true
Method Summary
Methods inherited from Net::HTTPRequest
Constructor Details
This class inherits a constructor from Net::HTTPRequest