Merge pull request #1996 from normanjaeckel/LanguageHeader
Added language header to internal server requests. Fixed #1981.
This commit is contained in:
commit
0cbb3fba01
@ -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,
|
||||||
|
Loading…
Reference in New Issue
Block a user