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

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

Instance Method Summary collapse

Instance Method Details

#callObject



192
193
194
195
196
197
198
199
200
201
# File 'lib/httpx/plugins/proxy.rb', line 192

def call
  super

  return unless @options.proxy

  case @state
  when :connecting
    consume
  end
end

#coalescable?Boolean

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

Returns:

  • (Boolean)


173
174
175
176
177
# File 'lib/httpx/plugins/proxy.rb', line 173

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

  false
end

#connecting?Boolean

Returns:

  • (Boolean)


186
187
188
189
190
# File 'lib/httpx/plugins/proxy.rb', line 186

def connecting?
  return super unless @options.proxy

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

#initializeObject



157
158
159
160
161
162
163
164
# File 'lib/httpx/plugins/proxy.rb', line 157

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.
  @origin = URI(@options.proxy.uri.origin)
end

#match?(uri, options) ⇒ Boolean

Returns:

  • (Boolean)


166
167
168
169
170
# File 'lib/httpx/plugins/proxy.rb', line 166

def match?(uri, options)
  return super unless @options.proxy

  super && @options.proxy == options.proxy
end

#resetObject



203
204
205
206
207
208
209
210
# File 'lib/httpx/plugins/proxy.rb', line 203

def reset
  return super unless @options.proxy

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

#send(request) ⇒ Object



179
180
181
182
183
184
# File 'lib/httpx/plugins/proxy.rb', line 179

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

  @pending << request
end