class Gem::Net::HTTP::Post
Class for representing HTTP method POST:
require 'rubygems/vendor/net-http/lib/net/http' uri = Gem::URI('http://example.com') hostname = uri.hostname # => "example.com" uri.path = '/posts' req = Gem::Net::HTTP::Post.new(uri) # => #<Gem::Net::HTTP::Post POST> req.body = '{"title": "foo","body": "bar","userId": 1}' req.content_type = 'application/json' res = Gem::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:
-
Gem::Net::HTTP.post
: sendsPOST
request, returns response object. -
Gem::Net::HTTP#post
: sendsPOST
request, returns response object.
Constants
- METHOD
- REQUEST_HAS_BODY
- RESPONSE_HAS_BODY