Class: ThreeScale::Client::HTTPClient

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/3scale/client/http_client.rb

Defined Under Namespace

Classes: BaseClient, NetHttp, NetHttpKeepAlive, NetHttpPersistent, PersistenceNotAvailable

Constant Summary collapse

USER_CLIENT_HEADER =
['X-3scale-User-Agent', "plugin-ruby-v#{VERSION}"]

Class Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ HTTPClient

Returns a new instance of HTTPClient.



17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/3scale/client/http_client.rb', line 17

def initialize(options)
  @secure = !!options[:secure]
  @host = options.fetch(:host)
  @persistent = options[:persistent]
  @port = options[:port] || (@secure ? 443 : 80)

  backend_class = @persistent ? self.class.persistent_backend : NetHttp or raise PersistenceNotAvailable
  backend_class.prepare

  @http = backend_class.new(@host, @port)
  @http.ssl! if @secure
end

Class Attribute Details

.persistent_backendObject

Returns the value of attribute persistent_backend.



155
156
157
# File 'lib/3scale/client/http_client.rb', line 155

def persistent_backend
  @persistent_backend
end