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

Defined in:
lib/httpx/plugins/proxy.rb

Instance Method Summary collapse

Instance Method Details

#callObject



268
269
270
271
272
273
274
275
276
277
# File 'lib/httpx/plugins/proxy.rb', line 268

def call
  super

  return unless @options.proxy

  case @state
  when :connecting
    consume
  end
end

#coalescable?(connection) ⇒ Boolean

Returns:

  • (Boolean)


239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
# File 'lib/httpx/plugins/proxy.rb', line 239

def coalescable?(connection)
  return super unless @options.proxy

  if @io.protocol == "h2" &&
     @origin.scheme == "https" &&
     connection.origin.scheme == "https" &&
     @io.can_verify_peer?
    # in proxied connections, .origin is the proxy ; Given names
    # are stored in .origins, this is what is used.
    origin = URI(connection.origins.first)
    @io.verify_hostname(origin.host)
  else
    @origin == connection.origin
  end
end

#connecting?Boolean

Returns:

  • (Boolean)


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

def connecting?
  return super unless @options.proxy

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

#initializeObject



228
229
230
231
232
233
234
235
236
237
# File 'lib/httpx/plugins/proxy.rb', line 228

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)
  @origin.host = proxy_uri.host
  @origin.port = proxy_uri.port
end

#resetObject



279
280
281
282
283
284
285
286
# File 'lib/httpx/plugins/proxy.rb', line 279

def reset
  return super unless @options.proxy

  @state = :open
  transition(:closing)
  transition(:closed)
  emit(:close)
end

#send(request) ⇒ Object



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

def send(request)
  return super unless @options.proxy
  return super unless connecting?

  @pending << request
end