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

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

Instance Method Summary collapse

Instance Method Details

#callObject



210
211
212
213
214
215
216
217
218
219
# File 'lib/httpx/plugins/proxy.rb', line 210

def call
  super

  return unless @options.proxy

  case @state
  when :connecting
    consume
  end
end

#coalescable?(connection) ⇒ Boolean



181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
# File 'lib/httpx/plugins/proxy.rb', line 181

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



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

def connecting?
  return super unless @options.proxy

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

#initializeObject



170
171
172
173
174
175
176
177
178
179
# File 'lib/httpx/plugins/proxy.rb', line 170

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



221
222
223
224
225
226
227
228
# File 'lib/httpx/plugins/proxy.rb', line 221

def reset
  return super unless @options.proxy

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

#send(request) ⇒ Object



197
198
199
200
201
202
# File 'lib/httpx/plugins/proxy.rb', line 197

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

  @pending << request
end