End of Life Ruby 3.1 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
instance method
Net::HTTPHeader#form_data=
form_data=(params, sep = '&')
lib/net/http/header.rb
View on GitHub ↗
# File tmp/rubies/ruby-3.1.3/lib/net/http/header.rb, line 417
def set_form_data(params, sep = '&')
query = URI.encode_www_form(params)
query.gsub!(/&/, sep) if sep != '&'
self.body = query
self.content_type = 'application/x-www-form-urlencoded'
end
Alias of #set_form_data
Set header fields and a body from HTML form data. params should be an Array of Arrays or a Hash containing HTML form data. Optional argument sep means data record separator.
Values are URL encoded as necessary and the content-type is set to application/x-www-form-urlencoded
Example:
Example
http.form_data = {"q" => "ruby", "lang" => "en"} http.form_data = {"q" => ["ruby", "perl"], "lang" => "en"} http.set_form_data({"q" => "ruby", "lang" => "en"}, ';')