hl7apy
hl7apy copied to clipboard
Encoding of mllp server is hard-coded to 'utf-8'
The mllp server encoding is hard-coded to 'utf-8'. This can result in errors if decoding of stream fails due to other encoding.
Solution:
change __init__
of MLLPServer:
def __init__(self, host, port, handlers, timeout=10, char_encoding='utf-8'):
self.host = host
self.port = port
self.handlers = handlers
self.timeout = timeout
self.char_encoding = char_encoding
TCPServer.__init__(self, (host, port), _MLLPRequestHandler)
remove hardcoded encoding in _MLLPRequestHandler and add to setup
:
self.encoding = self.server.char_encoding
I don't think this is an issue any more. The encoding can be customized like so:
from hl7apy.mllp import MLLPRequestHandler, MLLPServer
class CustomMLLPRequestHandler(MLLPRequestHandler):
encoding = "latin1"
MLLPServer(..., request_handler_class=CustomMLLPRequestHandler)