mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-27 02:24:18 +00:00
Add a finished flag to BaseHandler, and catch an extra OpenSSL exception.
This commit is contained in:
parent
f3237503a7
commit
47f862ae27
@ -20,7 +20,7 @@ class FileLike:
|
|||||||
while len(result) < length:
|
while len(result) < length:
|
||||||
try:
|
try:
|
||||||
data = self.o.read(length)
|
data = self.o.read(length)
|
||||||
except SSL.ZeroReturnError:
|
except (SSL.ZeroReturnError, SSL.SysCallError):
|
||||||
break
|
break
|
||||||
if not data:
|
if not data:
|
||||||
break
|
break
|
||||||
@ -86,6 +86,7 @@ class BaseHandler:
|
|||||||
|
|
||||||
self.client_address = client_address
|
self.client_address = client_address
|
||||||
self.server = server
|
self.server = server
|
||||||
|
self.finished = False
|
||||||
|
|
||||||
def convert_to_ssl(self, cert, key):
|
def convert_to_ssl(self, cert, key):
|
||||||
ctx = SSL.Context(SSL.SSLv23_METHOD)
|
ctx = SSL.Context(SSL.SSLv23_METHOD)
|
||||||
@ -97,6 +98,7 @@ class BaseHandler:
|
|||||||
self.wfile = FileLike(self.connection)
|
self.wfile = FileLike(self.connection)
|
||||||
|
|
||||||
def finish(self):
|
def finish(self):
|
||||||
|
self.finished = True
|
||||||
try:
|
try:
|
||||||
if not getattr(self.wfile, "closed", False):
|
if not getattr(self.wfile, "closed", False):
|
||||||
self.wfile.flush()
|
self.wfile.flush()
|
||||||
|
Loading…
Reference in New Issue
Block a user