'Aiohhtp Web.response Adding headers

Here is a method ends, which despatches matches in body and number of matches in headers.

.
. 
match_count = len(matches)
tot = {'total': match_count}
return web.json_response({"matches": fdata}, headers=tot)

While processing I am getting below Server error

File "/workspace/aio/server/aioenv/lib/python3.6/site-packages/aiohttp/http_writer.py", line 111, in write_headers
    buf = _serialize_headers(status_line, headers)
  File "aiohttp/_http_writer.pyx", line 138, in aiohttp._http_writer._serialize_headers
  File "aiohttp/_http_writer.pyx", line 110, in aiohttp._http_writer.to_str
TypeError: Cannot serialize non-str key 19

Somebody please explain. tot must be a dict. as docs explain how can I convert this into str



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source