Module: HTTPX::Plugins::Proxy::HTTP::InstanceMethods

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

Instance Method Summary collapse

Instance Method Details

#fetch_response(request, selector, options) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/httpx/plugins/proxy/http.rb', line 26

def fetch_response(request, selector, options)
  response = super

  if response &&
     response.is_a?(Response) &&
     response.status == 407 &&
     !request.headers.key?("proxy-authorization") &&
     response.headers.key?("proxy-authenticate") && 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(request, selector, options)
    return
  end

  response
end

#with_proxy_basic_auth(opts) ⇒ Object



14
15
16
# File 'lib/httpx/plugins/proxy/http.rb', line 14

def with_proxy_basic_auth(opts)
  with(proxy: opts.merge(scheme: "basic"))
end

#with_proxy_digest_auth(opts) ⇒ Object



18
19
20
# File 'lib/httpx/plugins/proxy/http.rb', line 18

def with_proxy_digest_auth(opts)
  with(proxy: opts.merge(scheme: "digest"))
end

#with_proxy_ntlm_auth(opts) ⇒ Object



22
23
24
# File 'lib/httpx/plugins/proxy/http.rb', line 22

def with_proxy_ntlm_auth(opts)
  with(proxy: opts.merge(scheme: "ntlm"))
end