Skip to content

Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →

class method

Net::HTTPRequest.new

(::String path, ?::Net::headers initheader) -> ::Net::HTTPRequest
(::URI::Generic uri, ?::Net::headers initheader) -> ::Net::HTTPRequest
new(path, initheader = nil)

Creates an HTTP request object for path.

initheader are the default headers to use. Net::HTTP adds Accept-Encoding to enable compression of the response body unless Accept-Encoding or Range are supplied in initheader.

also in 4.0 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0