Module: HTTPX::Plugins::Proxy::HTTP::ConnectionMethods
- Defined in:
- lib/httpx/plugins/proxy/http.rb,
sig/plugins/proxy/http.rbs
Instance Method Summary collapse
- #__http_on_connect(request, response) ⇒ void
- #__http_proxy_connect ⇒ void
- #handle_connect_error ⇒ Object
- #initialize ⇒ Object
- #on_error(error) ⇒ Object
Instance Method Details
#__http_on_connect(request, response) ⇒ void
This method returns an undefined value.
217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 |
# File 'lib/httpx/plugins/proxy/http.rb', line 217 def __http_on_connect(request, response) if response.is_a?(Response) && response.status == 200 req = @pending.first request_uri = req.uri @io = ProxySSL.new(@io, request_uri, @options) if request_uri.scheme == "https" transition(:connected) throw(:called) elsif response.is_a?(Response) && response.status == 407 && !request.headers.key?("proxy-authorization") && @options.proxy.can_authenticate?(response.headers["proxy-authenticate"]) request.transition(:idle) request.headers["proxy-authorization"] = @options.proxy.authenticate(request, response.headers["proxy-authenticate"]) send(request) else while (req = @pending.shift) response.finish! req.response = response req.emit_response(response) end reset end end |
#__http_proxy_connect ⇒ void
This method returns an undefined value.
199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 |
# File 'lib/httpx/plugins/proxy/http.rb', line 199 def __http_proxy_connect req = @pending.first enable_proxy_tunnel = ( req..enable_proxy_tunnel.nil? && req && req.uri.scheme == "https" ) || req..enable_proxy_tunnel if enable_proxy_tunnel # if the first request after CONNECT is to an https address, it is assumed that # all requests in the queue are not only ALL HTTPS, but they also share the certificate, # and therefore, will share the connection. # connect_request = @options.connect_request_class.new(req.uri, @options) send(connect_request) else handle_transition(:connected) end end |
#handle_connect_error ⇒ Object
92 93 94 95 96 97 98 99 |
# File 'lib/httpx/plugins/proxy/http.rb', line 92 def handle_connect_error(*) if @state == :connecting # proxy connect related requests should not be reenqueed @parser.reset end super end |
#initialize ⇒ Object
87 88 89 90 |
# File 'lib/httpx/plugins/proxy/http.rb', line 87 def initialize(*) @tunnel_parser = nil super end |
#on_error(error) ⇒ Object
101 102 103 104 105 |
# File 'lib/httpx/plugins/proxy/http.rb', line 101 def on_error(error, *) error = error.to_connection_error if error.is_a?(RequestTimeoutError) && connecting? super end |