Class: Sibit::HttpProxy
- Inherits:
-
Object
- Object
- Sibit::HttpProxy
- Defined in:
- lib/sibit/httpproxy.rb
Overview
HTTP client with proxy.
Accepts proxy address in format: host:port or user:password@host:port
- Author
-
Yegor Bugayenko ([email protected])
- Copyright
-
Copyright © 2019-2026 Yegor Bugayenko
- License
-
MIT
Instance Attribute Summary collapse
-
#host ⇒ Object
readonly
Returns the value of attribute host.
Instance Method Summary collapse
- #client(uri) ⇒ Object
-
#initialize(addr) ⇒ HttpProxy
constructor
A new instance of HttpProxy.
Constructor Details
#initialize(addr) ⇒ HttpProxy
Returns a new instance of HttpProxy.
18 19 20 |
# File 'lib/sibit/httpproxy.rb', line 18 def initialize(addr) @user, @password, @host, @port = parse(addr) end |
Instance Attribute Details
#host ⇒ Object (readonly)
Returns the value of attribute host.
22 23 24 |
# File 'lib/sibit/httpproxy.rb', line 22 def host @host end |
Instance Method Details
#client(uri) ⇒ Object
24 25 26 27 28 29 |
# File 'lib/sibit/httpproxy.rb', line 24 def client(uri) http = Net::HTTP.new(uri.host, uri.port, @host, @port.to_i, @user, @password) http.use_ssl = true http.read_timeout = 240 http end |