Created
October 30, 2014 21:36
-
-
Save gmanley/a81f2479b2d14067ce77 to your computer and use it in GitHub Desktop.
A collection of monkey patches I use when debugging with Charles. They force various http clients to use the `http_proxy` env variable as a proxy. You shouldn't actually add these to your project.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Net::HTTP | |
def proxy? | |
!!_env_proxy_uri | |
end | |
def proxy_address | |
_proxy_uri_from_env.host | |
end | |
def proxy_port | |
_proxy_uri_from_env.port | |
end | |
def _proxy_uri_from_env | |
URI(ENV['http_proxy']) | |
rescue | |
nil | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment