Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Encoding of mllp server is hard-coded to 'utf-8' #31

Open
LuukOost opened this issue Jul 11, 2017 · 1 comment
Open

Encoding of mllp server is hard-coded to 'utf-8' #31

LuukOost opened this issue Jul 11, 2017 · 1 comment

Comments

@LuukOost
Copy link

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
@gediminasz
Copy link

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants