Skip to content

Instantly share code, notes, and snippets.

@gmanley
Created October 30, 2014 21:36
Show Gist options
  • Save gmanley/a81f2479b2d14067ce77 to your computer and use it in GitHub Desktop.
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.
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