class

Halite::Options

Inherits Reference / Object

Options class

Init with splats options

o = Options.new(
  headers: {
    user_agent: "foobar"
  }
}
o.headers.class # => HTTP::Headers
o.cookies.class # => HTTP::Cookies

Set/Get timeout

Set it with connect_timeout/read_timeout/write_timeout keys, but get it call Timeout class.

o = Options.new(connect_timeout: 30, read_timeout: 30)
o.timeout.connect # => 30.0
o.timeout.read    # => 30.0
o.timeout.write   # => nil

Set/Get follow

Set it with follow/follow_strict keys, but get it call Follow class.

o = Options.new(follow: 3, follow_strict: false)
o.follow.hops   # => 3
o.follow.strict # => false

Constructors

new(options : Halite::Options)
Source
new(endpoint : String | URI | Nil = nil, headers : Hash(String, _) | NamedTuple | Nil = nil, cookies : Hash(String, _) | NamedTuple | Nil = nil, params : Hash(String, _) | NamedTuple | Nil = nil, form : Hash(String, _) | NamedTuple | Nil = nil, json : Hash(String, _) | NamedTuple | Nil = nil, raw : String | Nil = nil, connect_timeout : Int32 | Float64 | Time::Span | Nil = nil, read_timeout : Int32 | Float64 | Time::Span | Nil = nil, write_timeout : Int32 | Float64 | Time::Span | Nil = nil, follow : Int32 | Nil = nil, follow_strict : Bool | Nil = nil, tls : OpenSSL::SSL::Context::Client | Nil = nil, features = {} of String => Feature)
Source
new(*, endpoint : String | URI | Nil = nil, headers : Hash(String, _) | NamedTuple | Nil = nil, cookies : Hash(String, _) | NamedTuple | Nil = nil, params : Hash(String, _) | NamedTuple | Nil = nil, form : Hash(String, _) | NamedTuple | Nil = nil, json : Hash(String, _) | NamedTuple | Nil = nil, raw : String | Nil = nil, timeout : Halite::Options::Timeout = Timeout.new, follow : Halite::Options::Follow = Follow.new, tls : OpenSSL::SSL::Context::Client | Nil = nil, features : Hash(String, Halite::Feature) = {} of String => Feature)
Source
new(*, endpoint : URI | Nil, headers : HTTP::Headers, cookies : HTTP::Cookies, params : Hash(String, Type), form : Hash(String, Type), json : Hash(String, Type), raw : String | Nil = nil, timeout : Halite::Options::Timeout = Timeout.new, follow : Halite::Options::Follow = Follow.new, tls : OpenSSL::SSL::Context::Client | Nil = nil, features : Hash(String, Halite::Feature) = {} of String => Feature)
Source

Instance methods

clear!

Reset options

Source
connect_timeout

Alias Timeout.connect

Source
connect_timeout=(timeout : Int32 | Float64 | Time::Span)

Alias Timeout.connect=

Source
cookies
Source
cookies=(cookies : HTTP::Cookies)
Source
dup

Produces a shallow copy of obj—the instance variables of obj are copied, but not the objects they reference. dup copies the tainted state of obj.

Source
endpoint
Source
endpoint=(endpoint : URI | Nil)
Source
endpoint=(endpoint : String)

Set endpoint of request

Source
features
Source
features=(features : Hash(String, Feature))
Source
follow
Source
follow=(follow : Follow)
Source
follow=(hops : Int32)

Alias Follow.hops=

Source
follow_strict

Alias Follow.strict

Source
follow_strict=(strict : Bool)

Alias Follow.strict=

Source
form
Source
form=(form : Hash(String, Type))
Source
headers
Source
headers=(headers : HTTP::Headers)
Source
headers=(headers : Hash(String, _) | NamedTuple)

Set headers of request

Source
json
Source
json=(json : Hash(String, Type))
Source
logging

Get logging status

Source
logging=(enable : Bool)

Quick enable logging

By defaults, use Logging::Common as logging output.

Source

Merge with other Options and return new Halite::Options

Source

Merge with other Options and return self

Source
params
Source
params=(params : Hash(String, Type))
Source
raw=(raw : String | Nil)
Source
read_timeout

Alias Timeout.read

Source
read_timeout=(timeout : Int32 | Float64 | Time::Span)

Alias Timeout.read=

Source
timeout
Source
timeout=(timeout : Timeout)
Source
to_h

Returns this collection as a plain Hash.

Source
with_cookies(cookies : Hash(String, _) | NamedTuple) : Halite::Options

Returns Options self with given cookies combined.

Source
with_cookies(cookies : HTTP::Cookies) : Halite::Options

Returns Options self with given cookies combined.

Source
with_cookies

Alias with_cookies method.

Source
with_endpoint(endpoint : String | URI)
Source
with_features(name : String, opts : NamedTuple)

Returns Options self with feature name and options.

Source
with_features(name : String, feature : Feature)

Returns Options self with feature name and feature.

Source
with_features(*features)

Returns Options self with the name of features.

Source
with_features(feature_name : String, **opts)

Returns Options self with feature name and options.

Source
with_follow(follow = Follow::MAX_HOPS, strict = Follow::STRICT) : Halite::Options

Returns Options self with given max hops of redirect times.

# Automatically following redirects
options.with_follow
# A maximum of 3 subsequent redirects
options.with_follow(3)
# Set subsequent redirects
options.with_follow(3)
Source
with_headers(headers : Hash(String, _) | NamedTuple) : Halite::Options

Returns Options self with given headers combined.

Source
with_headers

Alias with_headers method.

Source
with_logging(logging : Halite::Logging::Abstract)

Returns Options self with given logging, depend on with_features.

Source
with_logging(format : String, **opts)

Returns Options iitself with given format and the options of format.

Source
with_timeout(connect : Int32 | Float64 | Time::Span | Nil = nil, read : Int32 | Float64 | Time::Span | Nil = nil, write : Int32 | Float64 | Time::Span | Nil = nil) : Halite::Options

Returns Options self with given connect, read timeout.

Source
write_timeout

Alias Timeout.write

Source
write_timeout=(timeout : Int32 | Float64 | Time::Span)

Alias Timeout.write=

Source

Nested types