Module: Wreq

Defined in:
lib/wreq_ruby/header.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/emulate.rb,
lib/wreq_ruby/response.rb

Overview

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

Defined Under Namespace

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

Constant Summary collapse

VERSION =

Current wreq gem version.

Returns:

  • (String)
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 (Boolean, nil)

    Whether to apply native default headers

  • 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 redirects; requires allow_redirects: true

  • 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 to an interface on supported platforms; unsupported platforms raise ArgumentError.

  • 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 serialized by the native encoder; Integer values retain arbitrary precision

  • body (String, Wreq::BodySender, nil)

    Raw or streaming request body

Returns:

Raises:

  • (TypeError, ArgumentError, Wreq::BuilderError)

    if a known option value cannot be converted, validated, or built



228
229
# File 'lib/wreq.rb', line 228

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 (Boolean, nil)

    Whether to apply native default headers

  • 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 redirects; requires allow_redirects: true

  • 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 to an interface on supported platforms; unsupported platforms raise ArgumentError.

  • 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 serialized by the native encoder; Integer values retain arbitrary precision

  • body (String, Wreq::BodySender, nil)

    Raw or streaming request body

Returns:

Raises:

  • (TypeError, ArgumentError, Wreq::BuilderError)

    if a known option value cannot be converted, validated, or built



96
97
# File 'lib/wreq.rb', line 96

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 (Boolean, nil)

    Whether to apply native default headers

  • 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 redirects; requires allow_redirects: true

  • 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 to an interface on supported platforms; unsupported platforms raise ArgumentError.

  • 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 serialized by the native encoder; Integer values retain arbitrary precision

  • body (String, Wreq::BodySender, nil)

    Raw or streaming request body

Returns:

Raises:

  • (TypeError, ArgumentError, Wreq::BuilderError)

    if a known option value cannot be converted, validated, or built



129
130
# File 'lib/wreq.rb', line 129

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 (Boolean, nil)

    Whether to apply native default headers

  • 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 redirects; requires allow_redirects: true

  • 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 to an interface on supported platforms; unsupported platforms raise ArgumentError.

  • 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 serialized by the native encoder; Integer values retain arbitrary precision

  • body (String, Wreq::BodySender, nil)

    Raw or streaming request body

Returns:

Raises:

  • (TypeError, ArgumentError, Wreq::BuilderError)

    if a known option value cannot be converted, validated, or built



261
262
# File 'lib/wreq.rb', line 261

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 (Boolean, nil)

    Whether to apply native default headers

  • 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 redirects; requires allow_redirects: true

  • 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 to an interface on supported platforms; unsupported platforms raise ArgumentError.

  • 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 serialized by the native encoder; Integer values retain arbitrary precision

  • body (String, Wreq::BodySender, nil)

    Raw or streaming request body

Returns:

Raises:

  • (TypeError, ArgumentError, Wreq::BuilderError)

    if a known option value cannot be converted, validated, or built



327
328
# File 'lib/wreq.rb', line 327

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 (Boolean, nil)

    Whether to apply native default headers

  • 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 redirects; requires allow_redirects: true

  • 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 to an interface on supported platforms; unsupported platforms raise ArgumentError.

  • 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 serialized by the native encoder; Integer values retain arbitrary precision

  • body (String, Wreq::BodySender, nil)

    Raw or streaming request body

Returns:

Raises:

  • (TypeError, ArgumentError, Wreq::BuilderError)

    if a known option value cannot be converted, validated, or built



162
163
# File 'lib/wreq.rb', line 162

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 (Boolean, nil)

    Whether to apply native default headers

  • 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 redirects; requires allow_redirects: true

  • 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 to an interface on supported platforms; unsupported platforms raise ArgumentError.

  • 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 serialized by the native encoder; Integer values retain arbitrary precision

  • body (String, Wreq::BodySender, nil)

    Raw or streaming request body

Returns:

Raises:

  • (TypeError, ArgumentError, Wreq::BuilderError)

    if a known option value cannot be converted, validated, or built



195
196
# File 'lib/wreq.rb', line 195

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 (Boolean, nil)

    Whether to apply native default headers

  • 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 redirects; requires allow_redirects: true

  • 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 to an interface on supported platforms; unsupported platforms raise ArgumentError.

  • 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 serialized by the native encoder; Integer values retain arbitrary precision

  • body (String, Wreq::BodySender, nil)

    Raw or streaming request body

Returns:

Raises:

  • (TypeError, ArgumentError, Wreq::BuilderError)

    if a known option value cannot be converted, validated, or built



63
64
# File 'lib/wreq.rb', line 63

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 (Boolean, nil)

    Whether to apply native default headers

  • 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 redirects; requires allow_redirects: true

  • 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 to an interface on supported platforms; unsupported platforms raise ArgumentError.

  • 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 serialized by the native encoder; Integer values retain arbitrary precision

  • body (String, Wreq::BodySender, nil)

    Raw or streaming request body

Returns:

Raises:

  • (TypeError, ArgumentError, Wreq::BuilderError)

    if a known option value cannot be converted, validated, or built



294
295
# File 'lib/wreq.rb', line 294

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