Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
_logger = logger
if qrandom:
_que = queue.RandomQueue ()
else:
_que = queue.Queue ()
_allow_redirects = allow_redirects
_force_h1 = request_handler.RequestHandler.FORCE_HTTP_11 = force_http1
if not use_pool:
asynconnect.AsynConnect.keep_connect = use_pool
asynconnect.AsynSSLConnect.keep_connect = use_pool
if not _force_h1:
asynconnect.AsynConnect.fifo_class = await_fifo
asynconnect.AsynSSLConnect.fifo_class = await_fifo
http2.MAX_HTTP2_CONCURRENT_STREAMS = http2_constreams
_workers = workers
_concurrent = workers
if not force_http1:
_concurrent = workers * http2_constreams
elif http2_constreams:
pass
#_logger ("parameter http2_constreams is ignored", "warn")
if callback:
_cb_gateway = callback
if cookie:
ls.create (_logger)
numsent = self.socket.send (data)
if numsent:
self.set_event_time ()
return numsent
except ssl.SSLError as why:
if why.errno == ssl.SSL_ERROR_WANT_WRITE:
return 0
elif why.errno == ssl.SSL_ERROR_ZERO_RETURN:
self.handle_close (700, "Connection closed by SSL_ERROR_ZERO_RETURN")
return 0
else:
raise
class AsynSSLProxyConnect (AsynSSLConnect, AsynConnect):
is_ssl = True
def __init__ (self, address, lock = None, logger = None):
AsynConnect.__init__ (self, address, lock, logger)
def handle_connect_event (self):
if self.established:
AsynSSLConnect.handle_connect_event (self)
else:
AsynConnect.handle_connect_event (self)
def recv (self, buffer_size):
if self._handshaked or self._handshaking:
return AsynSSLConnect.recv (self, buffer_size)
else:
return AsynConnect.recv (self, buffer_size)
def set_timeout (timeout):
for each in (asynconnect.AsynConnect, asynconnect.AsynSSLConnect, asynconnect.AsynSSLProxyConnect):
each.keep_alive = timeout
each.zombie_timeout = timeout
self.wrap_in_chunk = False
self.end_of_data = False
self.expect_disconnect = False
self.request = request
self.callback = callback
self.connection = connection
self.retry_count = 0
self.http2_handler = None
self.buffer = b""
self.response = None
self.callbacked = 0
self._ssl = isinstance (self.asyncon, asynconnect.AsynSSLConnect)
self.method, self.uri = (
self.request.get_method (),
self.asyncon.is_proxy () and self.request.uri or self.request.path
)
self.header = []
if request.get_address () is None:
request.set_address (self.asyncon.address)
def create_asyncon (self, server, scheme):
if scheme in ("https", "wss"):
__conn_class = asynconnect.AsynSSLConnect
__dft_Port = 443
elif scheme == "tunnel":
__conn_class = asynconnect.AsynConnect
__dft_Port = 443
elif scheme == "proxy":
__conn_class = asynconnect.AsynConnect
__dft_Port = 5000
elif scheme == "proxys":
__conn_class = asynconnect.AsynSSLProxyConnect
__dft_Port = 5000
else:
__conn_class = asynconnect.AsynConnect
__dft_Port = 80
if self.use_syn_connection:
if scheme == "https":
if logger is None:
logger = logger_f.screen_logger ()
_logger = logger
if qrandom:
_que = queue.RandomQueue ()
else:
_que = queue.Queue ()
_allow_redirects = allow_redirects
_force_h1 = request_handler.RequestHandler.FORCE_HTTP_11 = force_http1
if not use_pool:
asynconnect.AsynConnect.keep_connect = use_pool
asynconnect.AsynSSLConnect.keep_connect = use_pool
if not _force_h1:
asynconnect.AsynConnect.fifo_class = await_fifo
asynconnect.AsynSSLConnect.fifo_class = await_fifo
http2.MAX_HTTP2_CONCURRENT_STREAMS = http2_constreams
_workers = workers
_concurrent = workers
if not force_http1:
_concurrent = workers * http2_constreams
elif http2_constreams:
pass
#_logger ("parameter http2_constreams is ignored", "warn")
if callback:
_cb_gateway = callback
def send (self, data):
if self._handshaked or self._handshaking:
return AsynSSLConnect.send (self, data)
else:
return AsynConnect.send (self, data)
def handle_connect_event (self):
if self.established:
AsynSSLConnect.handle_connect_event (self)
else:
AsynConnect.handle_connect_event (self)
def recv (self, buffer_size):
if self._handshaked or self._handshaking:
return AsynSSLConnect.recv (self, buffer_size)
else:
return AsynConnect.recv (self, buffer_size)