mirror of
https://github.com/yt-dlp/yt-dlp
synced 2025-02-07 08:46:30 +01:00
patch SSLTransport to return b'' instead of 0 as EOF
Websockets only treats b'' as EOF
This commit is contained in:
parent
db14294b5c
commit
0efd83b31a
2 changed files with 16 additions and 2 deletions
|
@ -118,6 +118,13 @@ if urllib3:
|
|||
|
||||
def shutdown(self, *args, **kwargs):
|
||||
self.socket.shutdown(*args, **kwargs)
|
||||
|
||||
def _wrap_ssl_read(self, *args, **kwargs):
|
||||
res = super()._wrap_ssl_read(*args, **kwargs)
|
||||
if res == 0:
|
||||
# Websockets does not treat 0 as an EOF, rather only b''
|
||||
return b''
|
||||
return res
|
||||
else:
|
||||
SSLTransport = None
|
||||
|
||||
|
@ -270,9 +277,9 @@ class HTTPProxyWebSocketTestContext(HTTPProxyTestContext):
|
|||
handler.validate(request)
|
||||
ws = handler.send(request)
|
||||
ws.send('proxy_info')
|
||||
socks_info = ws.recv()
|
||||
proxy_info = ws.recv()
|
||||
ws.close()
|
||||
return json.loads(socks_info)
|
||||
return json.loads(proxy_info)
|
||||
|
||||
|
||||
class HTTPProxyWebSocketSecureTestContext(HTTPProxyWebSocketTestContext):
|
||||
|
|
|
@ -250,6 +250,13 @@ if urllib3_supported:
|
|||
def shutdown(self, *args, **kwargs):
|
||||
self.unwrap()
|
||||
self.socket.shutdown(*args, **kwargs)
|
||||
|
||||
def _wrap_ssl_read(self, *args, **kwargs):
|
||||
res = super()._wrap_ssl_read(*args, **kwargs)
|
||||
if res == 0:
|
||||
# Websockets does not treat 0 as an EOF, rather only b''
|
||||
return b''
|
||||
return res
|
||||
else:
|
||||
WebsocketsSSLTransport = None
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue