From: parmentelat Date: Tue, 15 Jan 2019 17:19:12 +0000 (+0100) Subject: bugfix; X-Git-Tag: plcapi-7.1-0~11 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=369f58f6e73a5821beaab7bfba650b0a6e14c96a;p=plcapi.git bugfix; content-length as served by our xmlrpc service was computed as the length of a str but it must instead be based on length of corresponding bytes, because that is what goes on the wire.. --- diff --git a/apache/plc.wsgi b/apache/plc.wsgi index 94829183..40a13277 100644 --- a/apache/plc.wsgi +++ b/apache/plc.wsgi @@ -16,7 +16,7 @@ def application(environ, start_response): try: status = '200 OK' if environ.get('REQUEST_METHOD') != 'POST': - content_type = 'text/html' + content_type = 'text/html; charset=utf-8' output = """ PLCAPI WSGI XML-RPC/SOAP Interface @@ -33,7 +33,7 @@ def application(environ, start_response): # object within different threads! api = PLCAPI() api.environ = environ - content_type = 'text/xml' + content_type = 'text/xml; charset=utf-8' ip = environ.get('REMOTE_ADDR') port = environ.get('REMOTE_PORT') output = api.handle((ip,port), environ.get('wsgi.input').read()) @@ -42,14 +42,14 @@ def application(environ, start_response): api.db.close() except Exception as err: status = '500 Internal Server Error' - content_type = 'text/html' + content_type = 'text/html; charset=utf-8' output = 'Internal Server Error' logger.exception("INTERNAL ERROR !!") # Write response + # with python3 wsgi expects a bytes object here + output = output.encode() response_headers = [('Content-type', '%s' % content_type), ('Content-Length', str(len(output)))] start_response(status, response_headers) - # with python3 wsgi expects a bytes object here - output = output.encode() return [output]