GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — snowflake-connector-python/proxy.py at master · byule/snowflake-connector-python

Expand file tree

/

proxy.py

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
46 lines (42 loc) · 1.55 KB
/

proxy.py

Copy path

File metadata and controls

46 lines (42 loc) · 1.55 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright (c) 2012-2019 Snowflake Computing Inc. All right reserved.
#
import os
from .compat import (TO_UNICODE)
def set_proxies(proxy_host, proxy_port, proxy_user=None, proxy_password=None):
"""
Set proxy dict for requests
"""
PREFIX_HTTP = 'http://'
PREFIX_HTTPS = 'https://'
proxies = None
if proxy_host and proxy_port:
if proxy_host.startswith(PREFIX_HTTP):
proxy_host = proxy_host[len(PREFIX_HTTP):]
elif proxy_host.startswith(PREFIX_HTTPS):
proxy_host = proxy_host[len(PREFIX_HTTPS):]
if proxy_user or proxy_password:
proxy_auth = u'{proxy_user}:{proxy_password}@'.format(
proxy_user=proxy_user if proxy_user is not None else '',
proxy_password=proxy_password if proxy_password is not
None else ''
)
else:
proxy_auth = u''
proxies = {
u'http': u'http://{proxy_auth}{proxy_host}:{proxy_port}'.format(
proxy_host=proxy_host,
proxy_port=TO_UNICODE(proxy_port),
proxy_auth=proxy_auth,
),
u'https': u'http://{proxy_auth}{proxy_host}:{proxy_port}'.format(
proxy_host=proxy_host,
proxy_port=TO_UNICODE(proxy_port),
proxy_auth=proxy_auth,
),
}
os.environ['HTTP_PROXY'] = proxies[u'http']
os.environ['HTTPS_PROXY'] = proxies[u'https']
return proxies
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.