Added language header to internal server requests. Fixed #1981.

This commit is contained in:
Norman Jäckel 2016-02-23 23:19:38 +01:00
parent ca5f707f74
commit 3ea4c507cf

View File

@ -113,8 +113,10 @@ class OpenSlidesSockJSConnection(SockJSConnection):
# Send out internal HTTP request to get data from the REST api. # Send out internal HTTP request to get data from the REST api.
for waiter in cls.waiters: for waiter in cls.waiters:
# Read waiter's former cookies and parse session cookie to new header object. # Initiat new headers object.
headers = HTTPHeaders() headers = HTTPHeaders()
# Read waiter's former cookies and parse session cookie to new header object.
try: try:
session_cookie = waiter.connection_info.cookies[settings.SESSION_COOKIE_NAME] session_cookie = waiter.connection_info.cookies[settings.SESSION_COOKIE_NAME]
except KeyError: except KeyError:
@ -122,6 +124,16 @@ class OpenSlidesSockJSConnection(SockJSConnection):
pass pass
else: else:
headers.add('Cookie', '%s=%s' % (settings.SESSION_COOKIE_NAME, session_cookie.value)) headers.add('Cookie', '%s=%s' % (settings.SESSION_COOKIE_NAME, session_cookie.value))
# Read waiter's language header.
try:
languages = waiter.connection_info.headers['Accept-Language']
except KeyError:
# There is no language header
pass
else:
headers.parse_line('Accept-Language: ' + languages)
# Setup uncompressed request. # Setup uncompressed request.
request = HTTPRequest( request = HTTPRequest(
url=url, url=url,