Skip to content

End of Life Ruby 3.1 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →

class method

Net::HTTP.post_form

post_form(url, params)

Posts HTML form data to the specified URI object. The form data must be provided as a Hash mapping from String to String. Example:

Example
{ "cmd" => "search", "q" => "ruby", "max" => "50" }

This method also does Basic Authentication if and only if url.user exists. But userinfo for authentication is deprecated (RFC3986). So this feature will be removed.

Example:

Example
require 'net/http'

Net::HTTP.post_form URI('http://www.example.com/search.cgi'),
                    { "q" => "ruby", "max" => "50" }
See also .post .Proxy .new .proxy_class? also in 4.1 · 4.0 · 3.4 · 3.3 · 3.2 · 3.0