Class: Sibit::HttpProxy

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#hostObject (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