File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed
Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change 1+ # Remove this module from LOAD_PATH, so we can load the real one
2+ gem_override_path = File . expand_path ( __dir__ )
3+ $LOAD_PATH. reject! { |path | File . expand_path ( path ) == gem_override_path }
4+
5+ # Load http.rb, and inject our proxy settings as the default for all requests
6+ require 'http'
7+ module HTTP
8+ module RequestHttpToolkitExtensions
9+ def initialize ( opts )
10+ if not opts [ :proxy ] or opts [ :proxy ] . keys . size < 2
11+ proxy_from_env = URI ( opts . fetch ( :uri ) . to_s ) . find_proxy
12+ opts [ :proxy ] = {
13+ proxy_address : proxy_from_env . host ,
14+ proxy_port : proxy_from_env . port
15+ }
16+ end
17+ super ( opts )
18+ end
19+ end
20+
21+ class Request
22+ prepend RequestHttpToolkitExtensions
23+ end
24+ end
25+
26+ # Put this override directory back on LOAD_PATH
27+ $LOAD_PATH. unshift ( gem_override_path )
You can’t perform that action at this time.
0 commit comments