Ruby 4.0 リファレンスマニュアル

singleton method Net::HTTP.put

put(url, data, header = nil) -> Net::HTTPResponseRuby 3.4 から[permalink][rdoc][edit]

URI で指定した対象にデータを PUT し、そのレスポンスを Net::HTTPResponse として返します。

このメソッドは以下とほぼ同じです。

require 'net/http'
Net::HTTP.start(url.hostname, url.port, use_ssl: url.scheme == 'https') {|http|
  http.put(url, data, header)
}
[PARAM] url:
PUT する対象を URI で指定します。
[PARAM] data:
PUT するデータを文字列で指定します。
[PARAM] header:
リクエストの HTTP ヘッダをハッシュで指定します。
require 'net/http'

uri = URI('http://www.example.com/index.html')
Net::HTTP.put(uri, 'query=subject&target=ruby', 'content-type' => 'application/x-www-form-urlencoded')

[SEE_ALSO] Net::HTTP#put, Net::HTTP::Put