-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Does this work with a http_proxy? #4
Comments
@fountainhead , this plugin uses requests to perform http request, so you can get help on setting proxy by http://docs.python-requests.org/en/latest/user/advanced/#proxies |
@fountainhead , I don't have proxy environment, you need to try it by yourself, sorry. |
@xjsender thanks for your response. Can you please guide me where to set the configuration for The code from the def api_request_native(url, data=None, token=None, https_proxy=None, method=None):
request = urllib.Request(url)
# print('API request url:', request.get_full_url())
if method:
request.get_method = lambda: method
token = token if token != None else token_auth_string()
request.add_header('Authorization', 'token ' + token)
request.add_header('Accept', 'application/json')
request.add_header('Content-Type', 'application/json')
if data is not None:
request.add_data(bytes(data.encode('utf8')))
# print('API request data:', request.get_data())
# print('API request header:', request.header_items())
https_proxy = https_proxy if https_proxy != None else settings.get('https_proxy')
if https_proxy:
opener = urllib.build_opener(urllib.HTTPHandler(), urllib.HTTPSHandler(),
urllib.ProxyHandler({'https': https_proxy}))
urllib.install_opener(opener)
try:
with contextlib.closing(urllib.urlopen(request)) as response:
if response.code == 204: # No Content
return None
else:
return json.loads(response.read().decode('utf8', 'ignore'))
except urllib.HTTPError as err:
with contextlib.closing(err):
raise SimpleHTTPError(err.code, err.read()) |
@fountainhead , just set environment variable for your operation system, you don't need to know anything about python. |
Thank you. I don't want to do this through the environment variable so that other code I have does not break. I got this working as follows. import urllib.request as urllib
proxyDict = {
"http" : "http://user:%23Cpassword%23C:server:port",
"https" : "http://user:%23Cpassword%23C:server:port"
}
self.res = requests.get(GIST_BASE_URL % "gists?per_page=1000",
headers=self.headers, proxies=proxyDict) Is there a way I can add |
I will release a new version to allow you to do it. thanks. |
@fountainhead , release v0.2.4 is available, I have added a new setting named |
Does this work with a http_proxy? I am getting a timeout error.
The text was updated successfully, but these errors were encountered: