Module: HTTPX::Plugins::Proxy::ConnectionMethods

Defined in:
lib/httpx/plugins/proxy.rb,
sig/plugins/proxy.rbs

Instance Method Summary collapse

Instance Method Details

#callObject



272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
# File 'lib/httpx/plugins/proxy.rb', line 272

def call
  super

  return unless @options.proxy

  case @state
  when :connecting
    consume
  end
rescue *PROXY_ERRORS => e
  if connecting?
    error = ProxyConnectionError.new(e.message)
    error.set_backtrace(e.backtrace)
    raise error
  end

  raise e
end

#connecting?Boolean

Returns:

  • (Boolean)


266
267
268
269
270
# File 'lib/httpx/plugins/proxy.rb', line 266

def connecting?
  return super unless @options.proxy

  super || @state == :connecting || @state == :connected
end

#initializeObject



253
254
255
256
257
258
259
260
# File 'lib/httpx/plugins/proxy.rb', line 253

def initialize(*)
  super
  return unless @options.proxy

  # redefining the connection origin as the proxy's URI,
  # as this will be used as the tcp peer ip.
  @proxy_uri = URI(@options.proxy.uri)
end

#peerObject



262
263
264
# File 'lib/httpx/plugins/proxy.rb', line 262

def peer
  @proxy_uri || super
end

#resetObject



291
292
293
294
295
296
297
298
# File 'lib/httpx/plugins/proxy.rb', line 291

def reset
  return super unless @options.proxy

  @state = :open

  super
  # emit(:close)
end