Module: Wreq

Defined in:
lib/wreq_ruby/response.rb,
lib/wreq.rb,
lib/wreq_ruby/http.rb,
lib/wreq_ruby/http.rb,
lib/wreq_ruby/client.rb,
lib/wreq_ruby/cookie.rb,
lib/wreq_ruby/header.rb,
lib/wreq_ruby/emulate.rb

Overview

Ruby API Extensions ========================

Defined Under Namespace

Classes: Client, Cookie, Emulation, Headers, Jar, Method, Platform, Profile, Response, StatusCode, Version

Constant Summary collapse

VERSION =
nil

Class Method Summary collapse

Class Method Details

.delete(url, **options) ⇒ Wreq::Response

Send an HTTP DELETE request.

Parameters:

  • url (String)

    Target URL

  • headers (Wreq::Headers, Hash{String=>String}, nil)

    Custom headers for this request

  • orig_headers (Array<String>, nil)

    Original header names used to preserve raw header order and HTTP/1 case-sensitive header handling

  • default_headers (Hash{String=>String}, nil)

    Default headers to merge

  • query (Hash, nil)

    URL query parameters

  • auth (String, nil)

    Authorization header value

  • bearer_auth (String, nil)

    Bearer token for Authorization header

  • basic_auth (Array<String>, nil)

    Username and password for basic auth

  • cookies (Hash{String=>String}, String, nil)

    Cookies to send

  • allow_redirects (Boolean, nil)

    Whether to follow redirects

  • max_redirects (Integer, nil)

    Maximum number of redirects to follow

  • gzip (Boolean, nil)

    Enable gzip compression

  • brotli (Boolean, nil)

    Enable Brotli compression

  • deflate (Boolean, nil)

    Enable deflate compression

  • zstd (Boolean, nil)

    Enable Zstandard compression

  • timeout (Integer, nil)

    Total request timeout (seconds)

  • read_timeout (Integer, nil)

    Per-chunk read timeout (seconds)

  • proxy (String, nil)

    Proxy server URI

  • local_address (String, nil)

    Bind the client's local source IP address (IPv4/IPv6). Useful on multi-homed hosts to originate connections from a specific address or enforce source routing. Examples: "192.168.1.10", "10.0.0.5", "2001:db8::1". The address must exist on the host and be routable or the connection may fail.

  • interface (String, nil)

    Bind the socket to a specific network interface via SO_BINDTODEVICE (e.g., "eth0", "wlan0", "tun0"). Effective only on systems that support the option (Linux/Android/Fuchsia) and typically requires privileges (root or CAP_NET_ADMIN).

  • emulation (Wreq::Emulation, nil)

    Device/OS emulation for this request

  • version (Wreq::Version, nil)

    HTTP version to use

  • form (Hash{String=>String}, nil)

    Form data (application/x-www-form-urlencoded)

  • json (Object, nil)

    JSON body (will be serialized)

  • body (String, IO, nil)

    Raw request body (string or stream)

Returns:



207
208
# File 'lib/wreq.rb', line 207

def self.delete(url, **options)
end

.get(url, **options) ⇒ Wreq::Response

Send an HTTP GET request.

Parameters:

  • url (String)

    Target URL

  • headers (Wreq::Headers, Hash{String=>String}, nil)

    Custom headers for this request

  • orig_headers (Array<String>, nil)

    Original header names used to preserve raw header order and HTTP/1 case-sensitive header handling

  • default_headers (Hash{String=>String}, nil)

    Default headers to merge

  • query (Hash, nil)

    URL query parameters

  • auth (String, nil)

    Authorization header value

  • bearer_auth (String, nil)

    Bearer token for Authorization header

  • basic_auth (Array<String>, nil)

    Username and password for basic auth

  • cookies (Hash{String=>String}, String, nil)

    Cookies to send

  • allow_redirects (Boolean, nil)

    Whether to follow redirects

  • max_redirects (Integer, nil)

    Maximum number of redirects to follow

  • gzip (Boolean, nil)

    Enable gzip compression

  • brotli (Boolean, nil)

    Enable Brotli compression

  • deflate (Boolean, nil)

    Enable deflate compression

  • zstd (Boolean, nil)

    Enable Zstandard compression

  • timeout (Integer, nil)

    Total request timeout (seconds)

  • read_timeout (Integer, nil)

    Per-chunk read timeout (seconds)

  • proxy (String, nil)

    Proxy server URI

  • local_address (String, nil)

    Bind the client's local source IP address (IPv4/IPv6). Useful on multi-homed hosts to originate connections from a specific address or enforce source routing. Examples: "192.168.1.10", "10.0.0.5", "2001:db8::1". The address must exist on the host and be routable or the connection may fail.

  • interface (String, nil)

    Bind the socket to a specific network interface via SO_BINDTODEVICE (e.g., "eth0", "wlan0", "tun0"). Effective only on systems that support the option (Linux/Android/Fuchsia) and typically requires privileges (root or CAP_NET_ADMIN).

  • emulation (Wreq::Emulation, nil)

    Device/OS emulation for this request

  • version (Wreq::Version, nil)

    HTTP version to use

  • form (Hash{String=>String}, nil)

    Form data (application/x-www-form-urlencoded)

  • json (Object, nil)

    JSON body (will be serialized)

  • body (String, IO, nil)

    Raw request body (string or stream)

Returns:



83
84
# File 'lib/wreq.rb', line 83

def self.get(url, **options)
end

.head(url, **options) ⇒ Wreq::Response

Send an HTTP HEAD request.

Parameters:

  • url (String)

    Target URL

  • headers (Wreq::Headers, Hash{String=>String}, nil)

    Custom headers for this request

  • orig_headers (Array<String>, nil)

    Original header names used to preserve raw header order and HTTP/1 case-sensitive header handling

  • default_headers (Hash{String=>String}, nil)

    Default headers to merge

  • query (Hash, nil)

    URL query parameters

  • auth (String, nil)

    Authorization header value

  • bearer_auth (String, nil)

    Bearer token for Authorization header

  • basic_auth (Array<String>, nil)

    Username and password for basic auth

  • cookies (Hash{String=>String}, String, nil)

    Cookies to send

  • allow_redirects (Boolean, nil)

    Whether to follow redirects

  • max_redirects (Integer, nil)

    Maximum number of redirects to follow

  • gzip (Boolean, nil)

    Enable gzip compression

  • brotli (Boolean, nil)

    Enable Brotli compression

  • deflate (Boolean, nil)

    Enable deflate compression

  • zstd (Boolean, nil)

    Enable Zstandard compression

  • timeout (Integer, nil)

    Total request timeout (seconds)

  • read_timeout (Integer, nil)

    Per-chunk read timeout (seconds)

  • proxy (String, nil)

    Proxy server URI

  • local_address (String, nil)

    Bind the client's local source IP address (IPv4/IPv6). Useful on multi-homed hosts to originate connections from a specific address or enforce source routing. Examples: "192.168.1.10", "10.0.0.5", "2001:db8::1". The address must exist on the host and be routable or the connection may fail.

  • interface (String, nil)

    Bind the socket to a specific network interface via SO_BINDTODEVICE (e.g., "eth0", "wlan0", "tun0"). Effective only on systems that support the option (Linux/Android/Fuchsia) and typically requires privileges (root or CAP_NET_ADMIN).

  • emulation (Wreq::Emulation, nil)

    Device/OS emulation for this request

  • version (Wreq::Version, nil)

    HTTP version to use

  • form (Hash{String=>String}, nil)

    Form data (application/x-www-form-urlencoded)

  • json (Object, nil)

    JSON body (will be serialized)

  • body (String, IO, nil)

    Raw request body (string or stream)

Returns:



114
115
# File 'lib/wreq.rb', line 114

def self.head(url, **options)
end

.options(url, **options) ⇒ Wreq::Response

Send an HTTP OPTIONS request.

Parameters:

  • url (String)

    Target URL

  • headers (Wreq::Headers, Hash{String=>String}, nil)

    Custom headers for this request

  • orig_headers (Array<String>, nil)

    Original header names used to preserve raw header order and HTTP/1 case-sensitive header handling

  • default_headers (Hash{String=>String}, nil)

    Default headers to merge

  • query (Hash, nil)

    URL query parameters

  • auth (String, nil)

    Authorization header value

  • bearer_auth (String, nil)

    Bearer token for Authorization header

  • basic_auth (Array<String>, nil)

    Username and password for basic auth

  • cookies (Hash{String=>String}, String, nil)

    Cookies to send

  • allow_redirects (Boolean, nil)

    Whether to follow redirects

  • max_redirects (Integer, nil)

    Maximum number of redirects to follow

  • gzip (Boolean, nil)

    Enable gzip compression

  • brotli (Boolean, nil)

    Enable Brotli compression

  • deflate (Boolean, nil)

    Enable deflate compression

  • zstd (Boolean, nil)

    Enable Zstandard compression

  • timeout (Integer, nil)

    Total request timeout (seconds)

  • read_timeout (Integer, nil)

    Per-chunk read timeout (seconds)

  • proxy (String, nil)

    Proxy server URI

  • local_address (String, nil)

    Bind the client's local source IP address (IPv4/IPv6). Useful on multi-homed hosts to originate connections from a specific address or enforce source routing. Examples: "192.168.1.10", "10.0.0.5", "2001:db8::1". The address must exist on the host and be routable or the connection may fail.

  • interface (String, nil)

    Bind the socket to a specific network interface via SO_BINDTODEVICE (e.g., "eth0", "wlan0", "tun0"). Effective only on systems that support the option (Linux/Android/Fuchsia) and typically requires privileges (root or CAP_NET_ADMIN).

  • emulation (Wreq::Emulation, nil)

    Device/OS emulation for this request

  • version (Wreq::Version, nil)

    HTTP version to use

  • form (Hash{String=>String}, nil)

    Form data (application/x-www-form-urlencoded)

  • json (Object, nil)

    JSON body (will be serialized)

  • body (String, IO, nil)

    Raw request body (string or stream)

Returns:



238
239
# File 'lib/wreq.rb', line 238

def self.options(url, **options)
end

.patch(url, **options) ⇒ Wreq::Response

Send an HTTP PATCH request.

Parameters:

  • url (String)

    Target URL

  • headers (Wreq::Headers, Hash{String=>String}, nil)

    Custom headers for this request

  • orig_headers (Array<String>, nil)

    Original header names used to preserve raw header order and HTTP/1 case-sensitive header handling

  • default_headers (Hash{String=>String}, nil)

    Default headers to merge

  • query (Hash, nil)

    URL query parameters

  • auth (String, nil)

    Authorization header value

  • bearer_auth (String, nil)

    Bearer token for Authorization header

  • basic_auth (Array<String>, nil)

    Username and password for basic auth

  • cookies (Hash{String=>String}, String, nil)

    Cookies to send

  • allow_redirects (Boolean, nil)

    Whether to follow redirects

  • max_redirects (Integer, nil)

    Maximum number of redirects to follow

  • gzip (Boolean, nil)

    Enable gzip compression

  • brotli (Boolean, nil)

    Enable Brotli compression

  • deflate (Boolean, nil)

    Enable deflate compression

  • zstd (Boolean, nil)

    Enable Zstandard compression

  • timeout (Integer, nil)

    Total request timeout (seconds)

  • read_timeout (Integer, nil)

    Per-chunk read timeout (seconds)

  • proxy (String, nil)

    Proxy server URI

  • local_address (String, nil)

    Bind the client's local source IP address (IPv4/IPv6). Useful on multi-homed hosts to originate connections from a specific address or enforce source routing. Examples: "192.168.1.10", "10.0.0.5", "2001:db8::1". The address must exist on the host and be routable or the connection may fail.

  • interface (String, nil)

    Bind the socket to a specific network interface via SO_BINDTODEVICE (e.g., "eth0", "wlan0", "tun0"). Effective only on systems that support the option (Linux/Android/Fuchsia) and typically requires privileges (root or CAP_NET_ADMIN).

  • emulation (Wreq::Emulation, nil)

    Device/OS emulation for this request

  • version (Wreq::Version, nil)

    HTTP version to use

  • form (Hash{String=>String}, nil)

    Form data (application/x-www-form-urlencoded)

  • json (Object, nil)

    JSON body (will be serialized)

  • body (String, IO, nil)

    Raw request body (string or stream)

Returns:



300
301
# File 'lib/wreq.rb', line 300

def self.patch(url, **options)
end

.post(url, **options) ⇒ Wreq::Response

Send an HTTP POST request.

Parameters:

  • url (String)

    Target URL

  • headers (Wreq::Headers, Hash{String=>String}, nil)

    Custom headers for this request

  • orig_headers (Array<String>, nil)

    Original header names used to preserve raw header order and HTTP/1 case-sensitive header handling

  • default_headers (Hash{String=>String}, nil)

    Default headers to merge

  • query (Hash, nil)

    URL query parameters

  • auth (String, nil)

    Authorization header value

  • bearer_auth (String, nil)

    Bearer token for Authorization header

  • basic_auth (Array<String>, nil)

    Username and password for basic auth

  • cookies (Hash{String=>String}, String, nil)

    Cookies to send

  • allow_redirects (Boolean, nil)

    Whether to follow redirects

  • max_redirects (Integer, nil)

    Maximum number of redirects to follow

  • gzip (Boolean, nil)

    Enable gzip compression

  • brotli (Boolean, nil)

    Enable Brotli compression

  • deflate (Boolean, nil)

    Enable deflate compression

  • zstd (Boolean, nil)

    Enable Zstandard compression

  • timeout (Integer, nil)

    Total request timeout (seconds)

  • read_timeout (Integer, nil)

    Per-chunk read timeout (seconds)

  • proxy (String, nil)

    Proxy server URI

  • local_address (String, nil)

    Bind the client's local source IP address (IPv4/IPv6). Useful on multi-homed hosts to originate connections from a specific address or enforce source routing. Examples: "192.168.1.10", "10.0.0.5", "2001:db8::1". The address must exist on the host and be routable or the connection may fail.

  • interface (String, nil)

    Bind the socket to a specific network interface via SO_BINDTODEVICE (e.g., "eth0", "wlan0", "tun0"). Effective only on systems that support the option (Linux/Android/Fuchsia) and typically requires privileges (root or CAP_NET_ADMIN).

  • emulation (Wreq::Emulation, nil)

    Device/OS emulation for this request

  • version (Wreq::Version, nil)

    HTTP version to use

  • form (Hash{String=>String}, nil)

    Form data (application/x-www-form-urlencoded)

  • json (Object, nil)

    JSON body (will be serialized)

  • body (String, IO, nil)

    Raw request body (string or stream)

Returns:



145
146
# File 'lib/wreq.rb', line 145

def self.post(url, **options)
end

.put(url, **options) ⇒ Wreq::Response

Send an HTTP PUT request.

Parameters:

  • url (String)

    Target URL

  • headers (Wreq::Headers, Hash{String=>String}, nil)

    Custom headers for this request

  • orig_headers (Array<String>, nil)

    Original header names used to preserve raw header order and HTTP/1 case-sensitive header handling

  • default_headers (Hash{String=>String}, nil)

    Default headers to merge

  • query (Hash, nil)

    URL query parameters

  • auth (String, nil)

    Authorization header value

  • bearer_auth (String, nil)

    Bearer token for Authorization header

  • basic_auth (Array<String>, nil)

    Username and password for basic auth

  • cookies (Hash{String=>String}, String, nil)

    Cookies to send

  • allow_redirects (Boolean, nil)

    Whether to follow redirects

  • max_redirects (Integer, nil)

    Maximum number of redirects to follow

  • gzip (Boolean, nil)

    Enable gzip compression

  • brotli (Boolean, nil)

    Enable Brotli compression

  • deflate (Boolean, nil)

    Enable deflate compression

  • zstd (Boolean, nil)

    Enable Zstandard compression

  • timeout (Integer, nil)

    Total request timeout (seconds)

  • read_timeout (Integer, nil)

    Per-chunk read timeout (seconds)

  • proxy (String, nil)

    Proxy server URI

  • local_address (String, nil)

    Bind the client's local source IP address (IPv4/IPv6). Useful on multi-homed hosts to originate connections from a specific address or enforce source routing. Examples: "192.168.1.10", "10.0.0.5", "2001:db8::1". The address must exist on the host and be routable or the connection may fail.

  • interface (String, nil)

    Bind the socket to a specific network interface via SO_BINDTODEVICE (e.g., "eth0", "wlan0", "tun0"). Effective only on systems that support the option (Linux/Android/Fuchsia) and typically requires privileges (root or CAP_NET_ADMIN).

  • emulation (Wreq::Emulation, nil)

    Device/OS emulation for this request

  • version (Wreq::Version, nil)

    HTTP version to use

  • form (Hash{String=>String}, nil)

    Form data (application/x-www-form-urlencoded)

  • json (Object, nil)

    JSON body (will be serialized)

  • body (String, IO, nil)

    Raw request body (string or stream)

Returns:



176
177
# File 'lib/wreq.rb', line 176

def self.put(url, **options)
end

.request(method, url, **options) ⇒ Wreq::Response

Send an HTTP request.

Parameters:

  • method (Wreq::Method)

    HTTP method to use

  • url (String)

    Target URL

  • headers (Wreq::Headers, Hash{String=>String}, nil)

    Custom headers for this request

  • orig_headers (Array<String>, nil)

    Original header names used to preserve raw header order and HTTP/1 case-sensitive header handling

  • default_headers (Hash{String=>String}, nil)

    Default headers to merge

  • query (Hash, nil)

    URL query parameters

  • auth (String, nil)

    Authorization header value

  • bearer_auth (String, nil)

    Bearer token for Authorization header

  • basic_auth (Array<String>, nil)

    Username and password for basic auth

  • cookies (Hash{String=>String}, String, nil)

    Cookies to send

  • allow_redirects (Boolean, nil)

    Whether to follow redirects

  • max_redirects (Integer, nil)

    Maximum number of redirects to follow

  • gzip (Boolean, nil)

    Enable gzip compression

  • brotli (Boolean, nil)

    Enable Brotli compression

  • deflate (Boolean, nil)

    Enable deflate compression

  • zstd (Boolean, nil)

    Enable Zstandard compression

  • timeout (Integer, nil)

    Total request timeout (seconds)

  • read_timeout (Integer, nil)

    Per-chunk read timeout (seconds)

  • proxy (String, nil)

    Proxy server URI

  • local_address (String, nil)

    Bind the client's local source IP address (IPv4/IPv6). Useful on multi-homed hosts to originate connections from a specific address or enforce source routing. Examples: "192.168.1.10", "10.0.0.5", "2001:db8::1". The address must exist on the host and be routable or the connection may fail.

  • interface (String, nil)

    Bind the socket to a specific network interface via SO_BINDTODEVICE (e.g., "eth0", "wlan0", "tun0"). Effective only on systems that support the option (Linux/Android/Fuchsia) and typically requires privileges (root or CAP_NET_ADMIN).

  • emulation (Wreq::Emulation, nil)

    Device/OS emulation for this request

  • version (Wreq::Version, nil)

    HTTP version to use

  • form (Hash{String=>String}, nil)

    Form data (application/x-www-form-urlencoded)

  • json (Object, nil)

    JSON body (will be serialized)

  • body (String, IO, nil)

    Raw request body (string or stream)

Returns:



52
53
# File 'lib/wreq.rb', line 52

def self.request(method, url, **options)
end

.trace(url, **options) ⇒ Wreq::Response

Send an HTTP TRACE request.

Parameters:

  • url (String)

    Target URL

  • headers (Wreq::Headers, Hash{String=>String}, nil)

    Custom headers for this request

  • orig_headers (Array<String>, nil)

    Original header names used to preserve raw header order and HTTP/1 case-sensitive header handling

  • default_headers (Hash{String=>String}, nil)

    Default headers to merge

  • query (Hash, nil)

    URL query parameters

  • auth (String, nil)

    Authorization header value

  • bearer_auth (String, nil)

    Bearer token for Authorization header

  • basic_auth (Array<String>, nil)

    Username and password for basic auth

  • cookies (Hash{String=>String}, String, nil)

    Cookies to send

  • allow_redirects (Boolean, nil)

    Whether to follow redirects

  • max_redirects (Integer, nil)

    Maximum number of redirects to follow

  • gzip (Boolean, nil)

    Enable gzip compression

  • brotli (Boolean, nil)

    Enable Brotli compression

  • deflate (Boolean, nil)

    Enable deflate compression

  • zstd (Boolean, nil)

    Enable Zstandard compression

  • timeout (Integer, nil)

    Total request timeout (seconds)

  • read_timeout (Integer, nil)

    Per-chunk read timeout (seconds)

  • proxy (String, nil)

    Proxy server URI

  • local_address (String, nil)

    Bind the client's local source IP address (IPv4/IPv6). Useful on multi-homed hosts to originate connections from a specific address or enforce source routing. Examples: "192.168.1.10", "10.0.0.5", "2001:db8::1". The address must exist on the host and be routable or the connection may fail.

  • interface (String, nil)

    Bind the socket to a specific network interface via SO_BINDTODEVICE (e.g., "eth0", "wlan0", "tun0"). Effective only on systems that support the option (Linux/Android/Fuchsia) and typically requires privileges (root or CAP_NET_ADMIN).

  • emulation (Wreq::Emulation, nil)

    Device/OS emulation for this request

  • version (Wreq::Version, nil)

    HTTP version to use

  • form (Hash{String=>String}, nil)

    Form data (application/x-www-form-urlencoded)

  • json (Object, nil)

    JSON body (will be serialized)

  • body (String, IO, nil)

    Raw request body (string or stream)

Returns:



269
270
# File 'lib/wreq.rb', line 269

def self.trace(url, **options)
end