Module: HTTP::Request::Proxy
- Included in:
- HTTP::Request
- Defined in:
- lib/http/request/proxy.rb
Overview
Proxy-related methods for HTTP requests
Instance Method Summary collapse
-
#connect_using_proxy(socket) ⇒ void
Setup tunnel through proxy for SSL request.
-
#include_proxy_authorization_header ⇒ void
Compute and add the Proxy-Authorization header.
-
#include_proxy_headers ⇒ void
Merges proxy headers into the request headers.
-
#proxy_authorization_header ⇒ String
Build the Proxy-Authorization header value.
-
#proxy_connect_header ⇒ String
Compute HTTP request header SSL proxy connection.
-
#proxy_connect_headers ⇒ HTTP::Headers
Headers to send with proxy connect request.
Instance Method Details
#connect_using_proxy(socket) ⇒ void
This method returns an undefined value.
Setup tunnel through proxy for SSL request
49 50 51 |
# File 'lib/http/request/proxy.rb', line 49 def connect_using_proxy(socket) Writer.new(socket, nil, proxy_connect_headers, proxy_connect_header).connect_through_proxy end |
#include_proxy_authorization_header ⇒ void
This method returns an undefined value.
Compute and add the Proxy-Authorization header
26 27 28 |
# File 'lib/http/request/proxy.rb', line 26 def headers[Headers::PROXY_AUTHORIZATION] = end |
#include_proxy_headers ⇒ void
This method returns an undefined value.
Merges proxy headers into the request headers
14 15 16 17 |
# File 'lib/http/request/proxy.rb', line 14 def include_proxy_headers headers.merge!(proxy[:proxy_headers]) if proxy.key?(:proxy_headers) if using_authenticated_proxy? end |
#proxy_authorization_header ⇒ String
Build the Proxy-Authorization header value
37 38 39 40 |
# File 'lib/http/request/proxy.rb', line 37 def digest = encode64(format("%s:%s", proxy.fetch(:proxy_username), proxy.fetch(:proxy_password))) "Basic #{digest}" end |
#proxy_connect_header ⇒ String
Compute HTTP request header SSL proxy connection
60 61 62 |
# File 'lib/http/request/proxy.rb', line 60 def proxy_connect_header "CONNECT #{host}:#{port} HTTP/#{version}" end |
#proxy_connect_headers ⇒ HTTP::Headers
Headers to send with proxy connect request
71 72 73 74 75 76 77 78 79 80 |
# File 'lib/http/request/proxy.rb', line 71 def proxy_connect_headers connect_headers = Headers.coerce( Headers::HOST => headers[Headers::HOST], Headers::USER_AGENT => headers[Headers::USER_AGENT] ) connect_headers[Headers::PROXY_AUTHORIZATION] = if using_authenticated_proxy? connect_headers.merge!(proxy[:proxy_headers]) if proxy.key?(:proxy_headers) connect_headers end |