module HTTPX::Plugins::Proxy::ConnectionMethods

  1. lib/httpx/plugins/proxy.rb

Methods

Public Class

  1. new

Public Instance

  1. call
  2. coalescable?
  3. connecting?
  4. reset

Public Class methods

new(*)
[show source]
    # File lib/httpx/plugins/proxy.rb
214 def initialize(*)
215   super
216   return unless @options.proxy
217 
218   # redefining the connection origin as the proxy's URI,
219   # as this will be used as the tcp peer ip.
220   proxy_uri = URI(@options.proxy.uri)
221   @origin.host = proxy_uri.host
222   @origin.port = proxy_uri.port
223 end

Public Instance methods

call()
[show source]
    # File lib/httpx/plugins/proxy.rb
247 def call
248   super
249 
250   return unless @options.proxy
251 
252   case @state
253   when :connecting
254     consume
255   end
256 end
coalescable?(connection)
[show source]
    # File lib/httpx/plugins/proxy.rb
225 def coalescable?(connection)
226   return super unless @options.proxy
227 
228   if @io.protocol == "h2" &&
229      @origin.scheme == "https" &&
230      connection.origin.scheme == "https" &&
231      @io.can_verify_peer?
232     # in proxied connections, .origin is the proxy ; Given names
233     # are stored in .origins, this is what is used.
234     origin = URI(connection.origins.first)
235     @io.verify_hostname(origin.host)
236   else
237     @origin == connection.origin
238   end
239 end
connecting?()
[show source]
    # File lib/httpx/plugins/proxy.rb
241 def connecting?
242   return super unless @options.proxy
243 
244   super || @state == :connecting || @state == :connected
245 end
reset()
[show source]
    # File lib/httpx/plugins/proxy.rb
258 def reset
259   return super unless @options.proxy
260 
261   @state = :open
262 
263   super
264   emit(:close)
265 end