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

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

Instance Method Summary collapse

Instance Method Details

#call ⇒ Object



293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
# File 'lib/httpx/plugins/proxy.rb', line 293

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?(*args) ⇒ Boolean

Returns:

  • (Boolean)


287
288
289
290
291
# File 'lib/httpx/plugins/proxy.rb', line 287

def connecting?(*args)
  return super unless @options.proxy

  super || proxy_connecting?(*args)
end

#initialize ⇒ Object



274
275
276
277
278
279
280
281
# File 'lib/httpx/plugins/proxy.rb', line 274

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 = @options.proxy.uri
end

#peer ⇒ Object



283
284
285
# File 'lib/httpx/plugins/proxy.rb', line 283

def peer
  @proxy_uri || super
end