class Halite::Options
- Halite::Options
- Reference
- Object
Overview
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
Defined in:
halite/options.crhalite/options/follow.cr
halite/options/timeout.cr
Constructors
- .new(options : Halite::Options)
- .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)
- .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)
- .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)
Instance Method Summary
-
#clear! : Halite::Options
Reset options
-
#connect_timeout
Alias
Timeout.connect
-
#connect_timeout=(timeout : Int32 | Float64 | Time::Span)
Alias
Timeout.connect=
- #cookies : HTTP::Cookies
- #cookies=(cookies : HTTP::Cookies)
-
#dup
Produces a shallow copy of obj—the instance variables of obj are copied, but not the objects they reference.
- #endpoint : URI | Nil
- #endpoint=(endpoint : URI | Nil)
-
#endpoint=(endpoint : String)
Set endpoint of request
- #features : Hash(String, Feature)
- #features=(features : Hash(String, Feature))
- #follow : Follow
- #follow=(follow : Follow)
-
#follow=(hops : Int32)
Alias
Follow.hops=
-
#follow_strict
Alias
Follow.strict
-
#follow_strict=(strict : Bool)
Alias
Follow.strict=
- #form : Hash(String, Type)
- #form=(form : Hash(String, Type))
- #headers : HTTP::Headers
- #headers=(headers : HTTP::Headers)
-
#headers=(headers : Hash(String, _) | NamedTuple)
Set headers of request
- #json : Hash(String, Type)
- #json=(json : Hash(String, Type))
-
#logging : Bool
Get logging status
-
#logging=(enable : Bool)
Quick enable logging
-
#merge(other : Halite::Options) : Halite::Options
Merge with other
Options
and return newHalite::Options
-
#merge!(other : Halite::Options) : Halite::Options
Merge with other
Options
and return self - #params : Hash(String, Type)
- #params=(params : Hash(String, Type))
- #raw : String | Nil
- #raw=(raw : String | Nil)
-
#read_timeout
Alias
Timeout.read
-
#read_timeout=(timeout : Int32 | Float64 | Time::Span)
Alias
Timeout.read=
- #timeout : Timeout
- #timeout=(timeout : Timeout)
- #tls : OpenSSL::SSL::Context::Client | Nil
- #tls=(tls : OpenSSL::SSL::Context::Client | Nil)
-
#to_h
Returns this collection as a plain Hash.
-
#with_cookies(cookies : Hash(String, _) | NamedTuple) : Halite::Options
Returns
Options
self with given cookies combined. -
#with_cookies(cookies : HTTP::Cookies) : Halite::Options
Returns
Options
self with given cookies combined. -
#with_cookies(cookie : HTTP::Cookie) : Halite::Options
Returns
Options
self with given cookies combined. -
#with_cookies(**cookies) : Halite::Options
Alias
#with_cookies
method. - #with_endpoint(endpoint : String | URI)
-
#with_features(name : String, opts : NamedTuple)
Returns
Options
self with feature name and options. -
#with_features(name : String, feature : Feature)
Returns
Options
self with feature name and feature. -
#with_features(*features)
Returns
Options
self with the name of features. -
#with_features(feature_name : String, **opts)
Returns
Options
self with feature name and options. -
#with_follow(follow = Follow::MAX_HOPS, strict = Follow::STRICT) : Halite::Options
Returns
Options
self with given max hops of redirect times. -
#with_headers(headers : Hash(String, _) | NamedTuple) : Halite::Options
Returns
Options
self with given headers combined. -
#with_headers(**with_headers) : Halite::Options
Alias
#with_headers
method. -
#with_logging(logging : Halite::Logging::Abstract)
Returns
Options
self with given logging, depend on#with_features
. -
#with_logging(format : String, **opts)
Returns
Options
iitself with given format and the options of format. -
#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. -
#write_timeout
Alias
Timeout.write
-
#write_timeout=(timeout : Int32 | Float64 | Time::Span)
Alias
Timeout.write=
Constructor Detail
Instance Method Detail
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.
Quick enable logging
By defaults, use Logging::Common
as logging output.
Merge with other Options
and return new Halite::Options
Merge with other Options
and return self
Returns Options
self with given cookies combined.
Returns Options
self with given cookies combined.
Returns Options
self with given cookies combined.
Returns Options
self with feature name and options.
Returns Options
self with feature name and feature.
Returns Options
self with feature name and 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)
Returns Options
self with given headers combined.
Returns Options
self with given logging, depend on #with_features
.
Returns Options
iitself with given format and the options of format.
Returns Options
self with given connect, read timeout.