This repository has been archived by the owner on Nov 5, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 431
Proxies should never be used when querying GCE metadata server #114
Comments
erwanor
pushed a commit
to erwanor/oauth2client
that referenced
this issue
Jan 22, 2015
I filed googleapis/google-cloud-python#757 to make sure we are also doing the right thing. AFAICT we get around autodetected proxies (and from six.moves.http_client import HTTPConnection
import socket
host = '169.254.169.254'
uri_path = '/computeMetadata/v1/project/project-id'
headers = {'Metadata-Flavor': 'Google'}
connection = HTTPConnection(host, timeout=0.1)
RESPONSE_BODY = None
try:
connection.request('GET', uri_path, headers=headers)
response = connection.getresponse()
if response.status == 200:
RESPONSE_BODY = response.read()
except socket.error: # socket.timeout or socket.error(64, 'Host is down')
pass
finally:
connection.close() |
dhermes
added a commit
to dhermes/oauth2client
that referenced
this issue
Aug 28, 2015
This avoids the potential issue of urllib detecting a proxy and changing the actual request underneath our code. The basic httplib library does not have any proxy detection, so this is not even possible there. Fixes googleapis#114.
Merged
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Similar changes to https://codereview.appspot.com/187380044/ should be made.
The text was updated successfully, but these errors were encountered: