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. match?
  5. reset
  6. send
  7. to_io

Public Class methods

new (*)
[show source]
    # File lib/httpx/plugins/proxy.rb
132 def initialize(*)
133   super
134   return unless @options.proxy
135 
136   # redefining the connection origin as the proxy's URI,
137   # as this will be used as the tcp peer ip.
138   @origin = URI(@options.proxy.uri.origin)
139 end

Public Instance methods

call ()
[show source]
    # File lib/httpx/plugins/proxy.rb
179 def call
180   super
181   return unless @options.proxy
182 
183   case @state
184   when :connecting
185     consume
186   end
187 end
coalescable? (*)

should not coalesce connections here, as the IP is the IP of the proxy

[show source]
    # File lib/httpx/plugins/proxy.rb
148 def coalescable?(*)
149   return super unless @options.proxy
150 
151   false
152 end
connecting? ()
[show source]
    # File lib/httpx/plugins/proxy.rb
161 def connecting?
162   return super unless @options.proxy
163 
164   super || @state == :connecting || @state == :connected
165 end
match? (uri, options)
[show source]
    # File lib/httpx/plugins/proxy.rb
141 def match?(uri, options)
142   return super unless @options.proxy
143 
144   super && @options.proxy == options.proxy
145 end
reset ()
[show source]
    # File lib/httpx/plugins/proxy.rb
189 def reset
190   return super unless @options.proxy
191 
192   @state = :open
193   transition(:closing)
194   transition(:closed)
195   emit(:close)
196 end
send (request)
[show source]
    # File lib/httpx/plugins/proxy.rb
154 def send(request)
155   return super unless @options.proxy
156   return super unless connecting?
157 
158   @pending << request
159 end
to_io ()
[show source]
    # File lib/httpx/plugins/proxy.rb
167 def to_io
168   return super unless @options.proxy
169 
170   case @state
171   when :idle
172     transition(:connecting)
173   when :connected
174     transition(:open)
175   end
176   @io.to_io
177 end