MCPcopy Create free account
hub / github.com/boy-hack/hack-requests / _make_con

Method _make_con

HackRequests/HackRequests.py:76–101  ·  view source on GitHub ↗
(self, scheme, host, port, proxy=None)

Source from the content-addressed store, hash-verified

74 return conn
75
76 def _make_con(self, scheme, host, port, proxy=None):
77 if "https" != scheme:
78 if proxy:
79 con = client.HTTPConnection(
80 proxy[0], int(proxy[1]), timeout=self.timeout)
81 con.set_tunnel(host, port)
82 else:
83 con = client.HTTPConnection(host, port, timeout=self.timeout)
84 # con.connect()
85 return con
86 for p in self.protocol:
87 context = ssl._create_unverified_context(p)
88 try:
89 if proxy:
90 con = client.HTTPSConnection(
91 proxy[0], proxy[1], context=context,
92 timeout=self.timeout)
93 con.set_tunnel(host, port)
94 else:
95 con = client.HTTPSConnection(
96 host, port, context=context, timeout=self.timeout)
97 # con.connect()
98 return con
99 except ssl.SSLError:
100 pass
101 raise Exception('connect err')
102
103
104class hackRequests(object):

Callers 1

get_conMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected