class Net::HTTP::Put - Documentation for Ruby 4.0
Description: class Net::HTTP::Put: en. wikipedia.
Keywords: ruby,class,Net::HTTP::Put

🔍

No recent searches

# class Net::HTTP::Put

Class for representing HTTP method PUT:

    require 'net/http'
    uri = URI('http://example.com')
    hostname = uri.hostname # => "example.com"
    uri.path = '/posts'
    req = Net::HTTP::Put.new(uri) # => #<Net::HTTP::Put PUT>
    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: yes.

- Cacheable: no.

Related:

- `Net::HTTP.put`: sends `PUT` request, returns response object.

- `Net::HTTP#put`: sends `PUT` request, returns response object.