Ticket #4173: connectionlost.patch

File connectionlost.patch, 1.0 KB (added by mfenniak, 6 years ago)

patch for client-side server connection error

  • twisted/web/websocket.py

     
    1212"""
    1313
    1414
     15from twisted.internet.error import ConnectionDone
    1516from twisted.web.http import datetimeToString
    1617from twisted.web.server import Request, Site, version, unquote
    1718
     
    170171
    171172    def __init__(self, request):
    172173        self._request = request
    173         self._request.notifyFinish().addErrback(self._connectionLost)
     174        self._request.notifyFinish().addCallbacks(self._connectionLost, self._finishError)
    174175
    175176
     177    def _finishError(self, failure):
     178        """
     179        Traps ConnectionDone (client-side disconnect) and forwards the event to
     180        the L{WebSocketHandler}.
     181        """
     182        failure.trap(ConnectionDone)
     183        self._handler.connectionLost(failure)
     184
     185
    176186    def _attachHandler(self, handler):
    177187        """
    178188        Attach the given L{WebSocketHandler} to this transport.