Module: Wreq

Defined in:
lib/wreq_ruby/response.rb,
lib/wreq.rb,
lib/wreq_ruby/http.rb,
lib/wreq_ruby/emulation.rb

Overview

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

Defined Under Namespace

Classes: Emulation, EmulationDevice, EmulationOS, Method, 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 (Hash{String=>String}, nil)

    Custom headers for this request

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

    Original headers (raw, unmodified)

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

    Default headers to merge

  • query (Hash, nil)

    URL query parameters

  • 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)

  • 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 (Array<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

  • no_proxy (Boolean, nil)

    Disable proxy for this request

  • 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

Returns:



214
215
# File 'lib/wreq.rb', line 214

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

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

Send an HTTP GET request.

Parameters:

  • url (String)

    Target URL

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

    Custom headers for this request

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

    Original headers (raw, unmodified)

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

    Default headers to merge

  • query (Hash, nil)

    URL query parameters

  • 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)

  • 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 (Array<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

  • no_proxy (Boolean, nil)

    Disable proxy for this request

  • 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

Returns:



85
86
# File 'lib/wreq.rb', line 85

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

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

Returns HTTP response.

Parameters:

  • 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

  • no_proxy (Boolean, nil)

    Disable proxy for this request

  • 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

Returns:



118
119
# File 'lib/wreq.rb', line 118

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

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

Send an HTTP OPTIONS request.

Parameters:

  • url (String)

    Target URL

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

    Custom headers for this request

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

    Original headers (raw, unmodified)

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

    Default headers to merge

  • query (Hash, nil)

    URL query parameters

  • 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)

  • 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 (Array<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

  • no_proxy (Boolean, nil)

    Disable proxy for this request

  • 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

Returns:



246
247
# File 'lib/wreq.rb', line 246

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

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

Send an HTTP PATCH request.

Parameters:

  • url (String)

    Target URL

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

    Custom headers for this request

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

    Original headers (raw, unmodified)

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

    Default headers to merge

  • query (Hash, nil)

    URL query parameters

  • 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)

  • 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 (Array<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

  • no_proxy (Boolean, nil)

    Disable proxy for this request

  • 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

Returns:



310
311
# File 'lib/wreq.rb', line 310

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

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

Send an HTTP POST request.

Parameters:

  • url (String)

    Target URL

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

    Custom headers for this request

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

    Original headers (raw, unmodified)

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

    Default headers to merge

  • query (Hash, nil)

    URL query parameters

  • 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)

  • 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 (Array<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

  • no_proxy (Boolean, nil)

    Disable proxy for this request

  • 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

Returns:



150
151
# File 'lib/wreq.rb', line 150

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

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

Send an HTTP PUT request.

Parameters:

  • url (String)

    Target URL

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

    Custom headers for this request

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

    Original headers (raw, unmodified)

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

    Default headers to merge

  • query (Hash, nil)

    URL query parameters

  • 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)

  • 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 (Array<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

  • no_proxy (Boolean, nil)

    Disable proxy for this request

  • 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

Returns:



182
183
# File 'lib/wreq.rb', line 182

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 (Hash{String=>String}, nil)

    Custom headers for this request

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

    Original headers (raw, unmodified)

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

    Default headers to merge

  • query (Hash, nil)

    URL query parameters

  • 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)

  • 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 (Array<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

  • no_proxy (Boolean, nil)

    Disable proxy for this request

  • 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

Returns:



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

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

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

Send an HTTP TRACE request.

Parameters:

  • url (String)

    Target URL

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

    Custom headers for this request

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

    Original headers (raw, unmodified)

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

    Default headers to merge

  • query (Hash, nil)

    URL query parameters

  • 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)

  • 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 (Array<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

  • no_proxy (Boolean, nil)

    Disable proxy for this request

  • 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

Returns:



278
279
# File 'lib/wreq.rb', line 278

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