Fix novncproxy for python3

The getheader() function isn't available in python3 [1]. Instead one can
simply use get() similar to what is done in the websockify module that
this code is using.

[1] https://bugs.python.org/issue4773

Change-Id: I349742d80e0abeb7866eeeb647ce18948eff81f8
Partial-Bug: 1663593
This commit is contained in:
Jens Rosenboom
2017-02-15 08:19:17 +01:00
parent 2eb6c61c59
commit b726f2553c
2 changed files with 62 additions and 99 deletions

View File

@@ -86,7 +86,7 @@ class NovaProxyRequestHandlerBase(object):
# NoVNC uses it's own convention that forward token
# from the request to a cookie header, we should check
# also for this behavior
hcookie = self.headers.getheader('cookie')
hcookie = self.headers.get('cookie')
if hcookie:
cookie = Cookie.SimpleCookie()
for hcookie_part in hcookie.split(';'):
@@ -109,7 +109,7 @@ class NovaProxyRequestHandlerBase(object):
raise exception.InvalidToken(token=token)
# Verify Origin
expected_origin_hostname = self.headers.getheader('Host')
expected_origin_hostname = self.headers.get('Host')
if ':' in expected_origin_hostname:
e = expected_origin_hostname
if '[' in e and ']' in e:
@@ -118,7 +118,7 @@ class NovaProxyRequestHandlerBase(object):
expected_origin_hostname = e.split(':')[0]
expected_origin_hostnames = CONF.console.allowed_origins
expected_origin_hostnames.append(expected_origin_hostname)
origin_url = self.headers.getheader('Origin')
origin_url = self.headers.get('Origin')
# missing origin header indicates non-browser client which is OK
if origin_url is not None:
origin = urlparse.urlparse(origin_url)