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
  8. transition

Public Class methods

new (*)
[show source]
    # File lib/httpx/plugins/proxy.rb
147 def initialize(*)
148   super
149   return unless @options.proxy
150 
151   # redefining the connection origin as the proxy's URI,
152   # as this will be used as the tcp peer ip.
153   @origin = URI(@options.proxy.uri.origin)
154 end

Public Instance methods

call ()
[show source]
    # File lib/httpx/plugins/proxy.rb
194 def call
195   super
196   return unless @options.proxy
197 
198   case @state
199   when :connecting
200     consume
201   end
202 end
coalescable? (*)

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

[show source]
    # File lib/httpx/plugins/proxy.rb
163 def coalescable?(*)
164   return super unless @options.proxy
165 
166   false
167 end
connecting? ()
[show source]
    # File lib/httpx/plugins/proxy.rb
176 def connecting?
177   return super unless @options.proxy
178 
179   super || @state == :connecting || @state == :connected
180 end
match? (uri, options)
[show source]
    # File lib/httpx/plugins/proxy.rb
156 def match?(uri, options)
157   return super unless @options.proxy
158 
159   super && @options.proxy == options.proxy
160 end
reset ()
[show source]
    # File lib/httpx/plugins/proxy.rb
204 def reset
205   return super unless @options.proxy
206 
207   @state = :open
208   transition(:closing)
209   transition(:closed)
210   emit(:close)
211 end
send (request)
[show source]
    # File lib/httpx/plugins/proxy.rb
169 def send(request)
170   return super unless @options.proxy
171   return super unless connecting?
172 
173   @pending << request
174 end
to_io ()
[show source]
    # File lib/httpx/plugins/proxy.rb
182 def to_io
183   return super unless @options.proxy
184 
185   case @state
186   when :idle
187     transition(:connecting)
188   when :connected
189     transition(:open)
190   end
191   @io.to_io
192 end
transition (nextstate)
[show source]
    # File lib/httpx/plugins/proxy.rb
213 def transition(nextstate)
214   return super unless @options.proxy
215 
216   case nextstate
217   when :closing
218     @state = :open if @state == :connecting
219   end
220   super
221 end