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

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

Instance Method Summary collapse

Instance Method Details

#callObject



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

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)


148
149
150
151
152
# File 'lib/httpx/plugins/proxy.rb', line 148

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

  false
end

#connecting?Boolean

Returns:

  • (Boolean)


161
162
163
164
165
# File 'lib/httpx/plugins/proxy.rb', line 161

def connecting?
  return super unless @options.proxy

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

#initializeObject



132
133
134
135
136
137
138
139
# File 'lib/httpx/plugins/proxy.rb', line 132

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)


141
142
143
144
145
# File 'lib/httpx/plugins/proxy.rb', line 141

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

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

#resetObject



189
190
191
192
193
194
195
196
# File 'lib/httpx/plugins/proxy.rb', line 189

def reset
  return super unless @options.proxy

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

#send(request) ⇒ Object



154
155
156
157
158
159
# File 'lib/httpx/plugins/proxy.rb', line 154

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

  @pending << request
end

#to_ioObject



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

def to_io
  return super unless @options.proxy

  case @state
  when :idle
    transition(:connecting)
  when :connected
    transition(:open)
  end
  @io.to_io
end