Skip to content

Commit

Permalink
air: sending response headers as list of tuples
Browse files Browse the repository at this point in the history
to allow multiple 'set-cookie' entries
  • Loading branch information
rodja committed Sep 21, 2023
1 parent e1a5420 commit 19b5497
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions nicegui/air.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,11 @@ async def on_http(data: Dict[str, Any]) -> Dict[str, Any]:
if match:
new_js_object = match.group(1).decode().rstrip('}') + ", 'fly_instance_id' : '" + instance_id + "'}"
content = content.replace(match.group(0), f'const query = {new_js_object}'.encode())
response_headers = dict(response.headers)
response_headers['content-encoding'] = 'gzip'
response.headers.update({'content-encoding': 'gzip'})
compressed = gzip.compress(content)
response_headers['content-length'] = str(len(compressed))
response.headers.update({'content-length': str(len(compressed))})
# NOTE the same header can occur multiple times so we send them as list of tuples
response_headers = [(k, v) for k, v in response.headers.items()]
return {
'status_code': response.status_code,
'headers': response_headers,
Expand Down

0 comments on commit 19b5497

Please sign in to comment.