From 213b1eaa565b615fcf19df8dc28087d3819d601e Mon Sep 17 00:00:00 2001 From: Florin Stancu Date: Tue, 5 Nov 2019 15:34:48 +0200 Subject: [PATCH] Fix rest_cherrypy CORS OPTIONS request on Py3 resolves #55087 --- salt/netapi/rest_cherrypy/app.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/salt/netapi/rest_cherrypy/app.py b/salt/netapi/rest_cherrypy/app.py index 82615afb2977..988c8791fffc 100644 --- a/salt/netapi/rest_cherrypy/app.py +++ b/salt/netapi/rest_cherrypy/app.py @@ -820,9 +820,11 @@ def cors_tool(): resp_head['Connection'] = 'keep-alive' resp_head['Access-Control-Max-Age'] = '1400' - # CORS requests should short-circuit the other tools. - cherrypy.response.body = '' + # Note: CherryPy on Py3 uses binary objects for the response + # Python 2.6 also supports the byte prefix, so no need for conditionals + cherrypy.response.body = b'' cherrypy.response.status = 200 + # CORS requests should short-circuit the other tools. cherrypy.serving.request.handler = None # Needed to avoid the auth_tool check.