Files
CN2021/server/serversocket.py
2021-03-28 18:55:00 +02:00

21 lines
595 B
Python

from httplib.exceptions import BadRequest
from httplib.httpsocket import HTTPSocket
class ServerSocket(HTTPSocket):
"""
Wrapper class for a socket. Represents a client connected to this server.
"""
"""
Reads the next line decoded as `httpsocket.FORMAT`
@return: the decoded next line retrieved from the socket
@raise InvalidResponse: If the next line couldn't be decoded, but was expected to
"""
def read_line(self):
try:
return super().read_line()
except UnicodeDecodeError:
raise BadRequest("UnicodeDecodeError")