We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
ints in Cookies are not getting parsed correctly
<!--

Thanks for taking an interest in Scrapy!

If you have a question that starts with "How to...", please see the Scrapy Community page: https://scrapy.org/community/.
The GitHub issue tracker's purpose is to deal with bug reports and feature requests for the project itself.

Keep in mind that by filing an issue, you are expected to comply with Scrapy's Code of Conduct, including treating everyone with respect: https://github.com/scrapy/scrapy/blob/master/CODE_OF_CONDUCT.md

The following is a suggested template to structure your issue, you can find more guidelines at https://doc.scrapy.org/en/latest/contributing.html#reporting-bugs

-->

### Description

Using an int in a cookie causes the spider to not work. Replacing the int with a str fixes the problem.

### Steps to Reproduce

Failing Code Example:
```
request = scrapy.Request(
      url = url, 
      callback = callback
)
request.cookies['some_cookie'] = 1
```

Successful Code Example:
```
request = scrapy.Request(
      url = url, 
     callback = callback
)
request.cookies['some_cookie'] = '1'
```

**Expected behavior:** I expect that an int should be parsed to a str without me needing to do it myself.

**Actual behavior:** Get following error:

```
Traceback (most recent call last):
  File "C:\Users\Michael\AppData\Local\Programs\Python\Python39\lib\site-packages\twisted\internet\defer.py", line 1661, in _inlineCallbacks
    result = current_context.run(gen.send, result)
  File "C:\Users\Michael\AppData\Local\Programs\Python\Python39\lib\site-packages\scrapy\core\downloader\middleware.py", line 36, in process_request
    response = yield deferred_from_coro(method(request=request, spider=spider))
  File "C:\Users\Michael\AppData\Local\Programs\Python\Python39\lib\site-packages\scrapy\downloadermiddlewares\cookies.py", line 32, in process_request
    for cookie in self._get_request_cookies(jar, request):
  File "C:\Users\Michael\AppData\Local\Programs\Python\Python39\lib\site-packages\scrapy\downloadermiddlewares\cookies.py", line 109, in _get_request_cookies
    response = Response(request.url, headers={"Set-Cookie": formatted})
  File "C:\Users\Michael\AppData\Local\Programs\Python\Python39\lib\site-packages\scrapy\http\response\__init__.py", line 32, in __init__
    self.headers = Headers(headers or {})
  File "C:\Users\Michael\AppData\Local\Programs\Python\Python39\lib\site-packages\scrapy\http\headers.py", line 11, in __init__
    super().__init__(seq)
  File "C:\Users\Michael\AppData\Local\Programs\Python\Python39\lib\site-packages\scrapy\utils\datatypes.py", line 20, in __init__
    self.update(seq)
  File "C:\Users\Michael\AppData\Local\Programs\Python\Python39\lib\site-packages\scrapy\utils\datatypes.py", line 56, in update
    super().update(iseq)
  File "C:\Users\Michael\AppData\Local\Programs\Python\Python39\lib\site-packages\scrapy\utils\datatypes.py", line 55, in <genexpr>
    iseq = ((self.normkey(k), self.normvalue(v)) for k, v in seq)
  File "C:\Users\Michael\AppData\Local\Programs\Python\Python39\lib\site-packages\scrapy\http\headers.py", line 26, in normvalue
    return [self._tobytes(x) for x in value]
  File "C:\Users\Michael\AppData\Local\Programs\Python\Python39\lib\site-packages\scrapy\http\headers.py", line 26, in <listcomp>
  File "C:\Users\Michael\AppData\Local\Programs\Python\Python39\lib\site-packages\scrapy\downloadermiddlewares\cookies.py", line 108, in <genexpr>
    formatted = filter(None, (self._format_cookie(c, request) for c in cookies))
  File "C:\Users\Michael\AppData\Local\Programs\Python\Python39\lib\site-packages\scrapy\downloadermiddlewares\cookies.py", line 87, in _format_cookie
    decoded[key] = cookie[key].decode("utf8")
AttributeError: 'int' object has no attribute 'decode'
```

**Reproduces how often:** [What percentage of the time does it reproduce?]

### Versions

Scrapy       : 2.5.0
lxml         : 4.6.3.0
libxml2      : 2.9.5
cssselect    : 1.1.0
parsel       : 1.6.0
w3lib        : 1.22.0
Twisted      : 21.7.0
Python       : 3.9.7 (tags/v3.9.7:1016ef3, Aug 30 2021, 20:19:38) [MSC v.1929 64 bit (AMD64)]
pyOpenSSL    : 21.0.0 (OpenSSL 1.1.1l  24 Aug 2021)
cryptography : 35.0.0
Platform     : Windows-10-10.0.19043-SP0

### Additional context

from scrapy.http import Request

Failing Code Example:
```
request = scrapy.Request(
      url = url, 
      callback = callback
)
request.cookies['some_cookie'] = 1
```

Successful Code Example:
```
request = scrapy.Request(
      url = url, 
     callback = callback
)
request.cookies['some_cookie'] = '1'
```

(edited to add code formatting to the traceback)

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `scrapy/downloadermiddlewares/cookies.py`
Content:
```
1 import logging
2 from collections import defaultdict
3 
4 from scrapy.exceptions import NotConfigured
5 from scrapy.http import Response
6 from scrapy.http.cookies import CookieJar
7 from scrapy.utils.python import to_unicode
8 
9 
10 logger = logging.getLogger(__name__)
11 
12 
13 class CookiesMiddleware:
14     """This middleware enables working with sites that need cookies"""
15 
16     def __init__(self, debug=False):
17         self.jars = defaultdict(CookieJar)
18         self.debug = debug
19 
20     @classmethod
21     def from_crawler(cls, crawler):
22         if not crawler.settings.getbool('COOKIES_ENABLED'):
23             raise NotConfigured
24         return cls(crawler.settings.getbool('COOKIES_DEBUG'))
25 
26     def process_request(self, request, spider):
27         if request.meta.get('dont_merge_cookies', False):
28             return
29 
30         cookiejarkey = request.meta.get("cookiejar")
31         jar = self.jars[cookiejarkey]
32         for cookie in self._get_request_cookies(jar, request):
33             jar.set_cookie_if_ok(cookie, request)
34 
35         # set Cookie header
36         request.headers.pop('Cookie', None)
37         jar.add_cookie_header(request)
38         self._debug_cookie(request, spider)
39 
40     def process_response(self, request, response, spider):
41         if request.meta.get('dont_merge_cookies', False):
42             return response
43 
44         # extract cookies from Set-Cookie and drop invalid/expired cookies
45         cookiejarkey = request.meta.get("cookiejar")
46         jar = self.jars[cookiejarkey]
47         jar.extract_cookies(response, request)
48         self._debug_set_cookie(response, spider)
49 
50         return response
51 
52     def _debug_cookie(self, request, spider):
53         if self.debug:
54             cl = [to_unicode(c, errors='replace')
55                   for c in request.headers.getlist('Cookie')]
56             if cl:
57                 cookies = "\n".join(f"Cookie: {c}\n" for c in cl)
58                 msg = f"Sending cookies to: {request}\n{cookies}"
59                 logger.debug(msg, extra={'spider': spider})
60 
61     def _debug_set_cookie(self, response, spider):
62         if self.debug:
63             cl = [to_unicode(c, errors='replace')
64                   for c in response.headers.getlist('Set-Cookie')]
65             if cl:
66                 cookies = "\n".join(f"Set-Cookie: {c}\n" for c in cl)
67                 msg = f"Received cookies from: {response}\n{cookies}"
68                 logger.debug(msg, extra={'spider': spider})
69 
70     def _format_cookie(self, cookie, request):
71         """
72         Given a dict consisting of cookie components, return its string representation.
73         Decode from bytes if necessary.
74         """
75         decoded = {}
76         for key in ("name", "value", "path", "domain"):
77             if cookie.get(key) is None:
78                 if key in ("name", "value"):
79                     msg = "Invalid cookie found in request {}: {} ('{}' is missing)"
80                     logger.warning(msg.format(request, cookie, key))
81                     return
82                 continue
83             if isinstance(cookie[key], str):
84                 decoded[key] = cookie[key]
85             else:
86                 try:
87                     decoded[key] = cookie[key].decode("utf8")
88                 except UnicodeDecodeError:
89                     logger.warning("Non UTF-8 encoded cookie found in request %s: %s",
90                                    request, cookie)
91                     decoded[key] = cookie[key].decode("latin1", errors="replace")
92 
93         cookie_str = f"{decoded.pop('name')}={decoded.pop('value')}"
94         for key, value in decoded.items():  # path, domain
95             cookie_str += f"; {key.capitalize()}={value}"
96         return cookie_str
97 
98     def _get_request_cookies(self, jar, request):
99         """
100         Extract cookies from the Request.cookies attribute
101         """
102         if not request.cookies:
103             return []
104         elif isinstance(request.cookies, dict):
105             cookies = ({"name": k, "value": v} for k, v in request.cookies.items())
106         else:
107             cookies = request.cookies
108         formatted = filter(None, (self._format_cookie(c, request) for c in cookies))
109         response = Response(request.url, headers={"Set-Cookie": formatted})
110         return jar.make_cookies(response, request)
111
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/scrapy/downloadermiddlewares/cookies.py b/scrapy/downloadermiddlewares/cookies.py
--- a/scrapy/downloadermiddlewares/cookies.py
+++ b/scrapy/downloadermiddlewares/cookies.py
@@ -80,8 +80,8 @@
                     logger.warning(msg.format(request, cookie, key))
                     return
                 continue
-            if isinstance(cookie[key], str):
-                decoded[key] = cookie[key]
+            if isinstance(cookie[key], (bool, float, int, str)):
+                decoded[key] = str(cookie[key])
             else:
                 try:
                     decoded[key] = cookie[key].decode("utf8")

{"golden_diff": "diff --git a/scrapy/downloadermiddlewares/cookies.py b/scrapy/downloadermiddlewares/cookies.py\n--- a/scrapy/downloadermiddlewares/cookies.py\n+++ b/scrapy/downloadermiddlewares/cookies.py\n@@ -80,8 +80,8 @@\n                     logger.warning(msg.format(request, cookie, key))\n                     return\n                 continue\n-            if isinstance(cookie[key], str):\n-                decoded[key] = cookie[key]\n+            if isinstance(cookie[key], (bool, float, int, str)):\n+                decoded[key] = str(cookie[key])\n             else:\n                 try:\n                     decoded[key] = cookie[key].decode(\"utf8\")\n", "issue": "ints in Cookies are not getting parsed correctly\n<!--\r\n\r\nThanks for taking an interest in Scrapy!\r\n\r\nIf you have a question that starts with \"How to...\", please see the Scrapy Community page: https://scrapy.org/community/.\r\nThe GitHub issue tracker's purpose is to deal with bug reports and feature requests for the project itself.\r\n\r\nKeep in mind that by filing an issue, you are expected to comply with Scrapy's Code of Conduct, including treating everyone with respect: https://github.com/scrapy/scrapy/blob/master/CODE_OF_CONDUCT.md\r\n\r\nThe following is a suggested template to structure your issue, you can find more guidelines at https://doc.scrapy.org/en/latest/contributing.html#reporting-bugs\r\n\r\n-->\r\n\r\n### Description\r\n\r\nUsing an int in a cookie causes the spider to not work. Replacing the int with a str fixes the problem.\r\n\r\n### Steps to Reproduce\r\n\r\nFailing Code Example:\r\n```\r\nrequest = scrapy.Request(\r\n      url = url, \r\n      callback = callback\r\n)\r\nrequest.cookies['some_cookie'] = 1\r\n```\r\n\r\nSuccessful Code Example:\r\n```\r\nrequest = scrapy.Request(\r\n      url = url, \r\n     callback = callback\r\n)\r\nrequest.cookies['some_cookie'] = '1'\r\n```\r\n\r\n**Expected behavior:** I expect that an int should be parsed to a str without me needing to do it myself.\r\n\r\n**Actual behavior:** Get following error:\r\n\r\n```\r\nTraceback (most recent call last):\r\n  File \"C:\\Users\\Michael\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\twisted\\internet\\defer.py\", line 1661, in _inlineCallbacks\r\n    result = current_context.run(gen.send, result)\r\n  File \"C:\\Users\\Michael\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\scrapy\\core\\downloader\\middleware.py\", line 36, in process_request\r\n    response = yield deferred_from_coro(method(request=request, spider=spider))\r\n  File \"C:\\Users\\Michael\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\scrapy\\downloadermiddlewares\\cookies.py\", line 32, in process_request\r\n    for cookie in self._get_request_cookies(jar, request):\r\n  File \"C:\\Users\\Michael\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\scrapy\\downloadermiddlewares\\cookies.py\", line 109, in _get_request_cookies\r\n    response = Response(request.url, headers={\"Set-Cookie\": formatted})\r\n  File \"C:\\Users\\Michael\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\scrapy\\http\\response\\__init__.py\", line 32, in __init__\r\n    self.headers = Headers(headers or {})\r\n  File \"C:\\Users\\Michael\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\scrapy\\http\\headers.py\", line 11, in __init__\r\n    super().__init__(seq)\r\n  File \"C:\\Users\\Michael\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\scrapy\\utils\\datatypes.py\", line 20, in __init__\r\n    self.update(seq)\r\n  File \"C:\\Users\\Michael\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\scrapy\\utils\\datatypes.py\", line 56, in update\r\n    super().update(iseq)\r\n  File \"C:\\Users\\Michael\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\scrapy\\utils\\datatypes.py\", line 55, in <genexpr>\r\n    iseq = ((self.normkey(k), self.normvalue(v)) for k, v in seq)\r\n  File \"C:\\Users\\Michael\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\scrapy\\http\\headers.py\", line 26, in normvalue\r\n    return [self._tobytes(x) for x in value]\r\n  File \"C:\\Users\\Michael\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\scrapy\\http\\headers.py\", line 26, in <listcomp>\r\n  File \"C:\\Users\\Michael\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\scrapy\\downloadermiddlewares\\cookies.py\", line 108, in <genexpr>\r\n    formatted = filter(None, (self._format_cookie(c, request) for c in cookies))\r\n  File \"C:\\Users\\Michael\\AppData\\Local\\Programs\\Python\\Python39\\lib\\site-packages\\scrapy\\downloadermiddlewares\\cookies.py\", line 87, in _format_cookie\r\n    decoded[key] = cookie[key].decode(\"utf8\")\r\nAttributeError: 'int' object has no attribute 'decode'\r\n```\r\n\r\n**Reproduces how often:** [What percentage of the time does it reproduce?]\r\n\r\n### Versions\r\n\r\nScrapy       : 2.5.0\r\nlxml         : 4.6.3.0\r\nlibxml2      : 2.9.5\r\ncssselect    : 1.1.0\r\nparsel       : 1.6.0\r\nw3lib        : 1.22.0\r\nTwisted      : 21.7.0\r\nPython       : 3.9.7 (tags/v3.9.7:1016ef3, Aug 30 2021, 20:19:38) [MSC v.1929 64 bit (AMD64)]\r\npyOpenSSL    : 21.0.0 (OpenSSL 1.1.1l  24 Aug 2021)\r\ncryptography : 35.0.0\r\nPlatform     : Windows-10-10.0.19043-SP0\r\n\r\n### Additional context\r\n\r\nfrom scrapy.http import Request\r\n\r\nFailing Code Example:\r\n```\r\nrequest = scrapy.Request(\r\n      url = url, \r\n      callback = callback\r\n)\r\nrequest.cookies['some_cookie'] = 1\r\n```\r\n\r\nSuccessful Code Example:\r\n```\r\nrequest = scrapy.Request(\r\n      url = url, \r\n     callback = callback\r\n)\r\nrequest.cookies['some_cookie'] = '1'\r\n```\r\n\r\n(edited to add code formatting to the traceback)\n", "before_files": [{"content": "import logging\nfrom collections import defaultdict\n\nfrom scrapy.exceptions import NotConfigured\nfrom scrapy.http import Response\nfrom scrapy.http.cookies import CookieJar\nfrom scrapy.utils.python import to_unicode\n\n\nlogger = logging.getLogger(__name__)\n\n\nclass CookiesMiddleware:\n    \"\"\"This middleware enables working with sites that need cookies\"\"\"\n\n    def __init__(self, debug=False):\n        self.jars = defaultdict(CookieJar)\n        self.debug = debug\n\n    @classmethod\n    def from_crawler(cls, crawler):\n        if not crawler.settings.getbool('COOKIES_ENABLED'):\n            raise NotConfigured\n        return cls(crawler.settings.getbool('COOKIES_DEBUG'))\n\n    def process_request(self, request, spider):\n        if request.meta.get('dont_merge_cookies', False):\n            return\n\n        cookiejarkey = request.meta.get(\"cookiejar\")\n        jar = self.jars[cookiejarkey]\n        for cookie in self._get_request_cookies(jar, request):\n            jar.set_cookie_if_ok(cookie, request)\n\n        # set Cookie header\n        request.headers.pop('Cookie', None)\n        jar.add_cookie_header(request)\n        self._debug_cookie(request, spider)\n\n    def process_response(self, request, response, spider):\n        if request.meta.get('dont_merge_cookies', False):\n            return response\n\n        # extract cookies from Set-Cookie and drop invalid/expired cookies\n        cookiejarkey = request.meta.get(\"cookiejar\")\n        jar = self.jars[cookiejarkey]\n        jar.extract_cookies(response, request)\n        self._debug_set_cookie(response, spider)\n\n        return response\n\n    def _debug_cookie(self, request, spider):\n        if self.debug:\n            cl = [to_unicode(c, errors='replace')\n                  for c in request.headers.getlist('Cookie')]\n            if cl:\n                cookies = \"\\n\".join(f\"Cookie: {c}\\n\" for c in cl)\n                msg = f\"Sending cookies to: {request}\\n{cookies}\"\n                logger.debug(msg, extra={'spider': spider})\n\n    def _debug_set_cookie(self, response, spider):\n        if self.debug:\n            cl = [to_unicode(c, errors='replace')\n                  for c in response.headers.getlist('Set-Cookie')]\n            if cl:\n                cookies = \"\\n\".join(f\"Set-Cookie: {c}\\n\" for c in cl)\n                msg = f\"Received cookies from: {response}\\n{cookies}\"\n                logger.debug(msg, extra={'spider': spider})\n\n    def _format_cookie(self, cookie, request):\n        \"\"\"\n        Given a dict consisting of cookie components, return its string representation.\n        Decode from bytes if necessary.\n        \"\"\"\n        decoded = {}\n        for key in (\"name\", \"value\", \"path\", \"domain\"):\n            if cookie.get(key) is None:\n                if key in (\"name\", \"value\"):\n                    msg = \"Invalid cookie found in request {}: {} ('{}' is missing)\"\n                    logger.warning(msg.format(request, cookie, key))\n                    return\n                continue\n            if isinstance(cookie[key], str):\n                decoded[key] = cookie[key]\n            else:\n                try:\n                    decoded[key] = cookie[key].decode(\"utf8\")\n                except UnicodeDecodeError:\n                    logger.warning(\"Non UTF-8 encoded cookie found in request %s: %s\",\n                                   request, cookie)\n                    decoded[key] = cookie[key].decode(\"latin1\", errors=\"replace\")\n\n        cookie_str = f\"{decoded.pop('name')}={decoded.pop('value')}\"\n        for key, value in decoded.items():  # path, domain\n            cookie_str += f\"; {key.capitalize()}={value}\"\n        return cookie_str\n\n    def _get_request_cookies(self, jar, request):\n        \"\"\"\n        Extract cookies from the Request.cookies attribute\n        \"\"\"\n        if not request.cookies:\n            return []\n        elif isinstance(request.cookies, dict):\n            cookies = ({\"name\": k, \"value\": v} for k, v in request.cookies.items())\n        else:\n            cookies = request.cookies\n        formatted = filter(None, (self._format_cookie(c, request) for c in cookies))\n        response = Response(request.url, headers={\"Set-Cookie\": formatted})\n        return jar.make_cookies(response, request)\n", "path": "scrapy/downloadermiddlewares/cookies.py"}], "after_files": [{"content": "import logging\nfrom collections import defaultdict\n\nfrom scrapy.exceptions import NotConfigured\nfrom scrapy.http import Response\nfrom scrapy.http.cookies import CookieJar\nfrom scrapy.utils.python import to_unicode\n\n\nlogger = logging.getLogger(__name__)\n\n\nclass CookiesMiddleware:\n    \"\"\"This middleware enables working with sites that need cookies\"\"\"\n\n    def __init__(self, debug=False):\n        self.jars = defaultdict(CookieJar)\n        self.debug = debug\n\n    @classmethod\n    def from_crawler(cls, crawler):\n        if not crawler.settings.getbool('COOKIES_ENABLED'):\n            raise NotConfigured\n        return cls(crawler.settings.getbool('COOKIES_DEBUG'))\n\n    def process_request(self, request, spider):\n        if request.meta.get('dont_merge_cookies', False):\n            return\n\n        cookiejarkey = request.meta.get(\"cookiejar\")\n        jar = self.jars[cookiejarkey]\n        for cookie in self._get_request_cookies(jar, request):\n            jar.set_cookie_if_ok(cookie, request)\n\n        # set Cookie header\n        request.headers.pop('Cookie', None)\n        jar.add_cookie_header(request)\n        self._debug_cookie(request, spider)\n\n    def process_response(self, request, response, spider):\n        if request.meta.get('dont_merge_cookies', False):\n            return response\n\n        # extract cookies from Set-Cookie and drop invalid/expired cookies\n        cookiejarkey = request.meta.get(\"cookiejar\")\n        jar = self.jars[cookiejarkey]\n        jar.extract_cookies(response, request)\n        self._debug_set_cookie(response, spider)\n\n        return response\n\n    def _debug_cookie(self, request, spider):\n        if self.debug:\n            cl = [to_unicode(c, errors='replace')\n                  for c in request.headers.getlist('Cookie')]\n            if cl:\n                cookies = \"\\n\".join(f\"Cookie: {c}\\n\" for c in cl)\n                msg = f\"Sending cookies to: {request}\\n{cookies}\"\n                logger.debug(msg, extra={'spider': spider})\n\n    def _debug_set_cookie(self, response, spider):\n        if self.debug:\n            cl = [to_unicode(c, errors='replace')\n                  for c in response.headers.getlist('Set-Cookie')]\n            if cl:\n                cookies = \"\\n\".join(f\"Set-Cookie: {c}\\n\" for c in cl)\n                msg = f\"Received cookies from: {response}\\n{cookies}\"\n                logger.debug(msg, extra={'spider': spider})\n\n    def _format_cookie(self, cookie, request):\n        \"\"\"\n        Given a dict consisting of cookie components, return its string representation.\n        Decode from bytes if necessary.\n        \"\"\"\n        decoded = {}\n        for key in (\"name\", \"value\", \"path\", \"domain\"):\n            if cookie.get(key) is None:\n                if key in (\"name\", \"value\"):\n                    msg = \"Invalid cookie found in request {}: {} ('{}' is missing)\"\n                    logger.warning(msg.format(request, cookie, key))\n                    return\n                continue\n            if isinstance(cookie[key], (bool, float, int, str)):\n                decoded[key] = str(cookie[key])\n            else:\n                try:\n                    decoded[key] = cookie[key].decode(\"utf8\")\n                except UnicodeDecodeError:\n                    logger.warning(\"Non UTF-8 encoded cookie found in request %s: %s\",\n                                   request, cookie)\n                    decoded[key] = cookie[key].decode(\"latin1\", errors=\"replace\")\n\n        cookie_str = f\"{decoded.pop('name')}={decoded.pop('value')}\"\n        for key, value in decoded.items():  # path, domain\n            cookie_str += f\"; {key.capitalize()}={value}\"\n        return cookie_str\n\n    def _get_request_cookies(self, jar, request):\n        \"\"\"\n        Extract cookies from the Request.cookies attribute\n        \"\"\"\n        if not request.cookies:\n            return []\n        elif isinstance(request.cookies, dict):\n            cookies = ({\"name\": k, \"value\": v} for k, v in request.cookies.items())\n        else:\n            cookies = request.cookies\n        formatted = filter(None, (self._format_cookie(c, request) for c in cookies))\n        response = Response(request.url, headers={\"Set-Cookie\": formatted})\n        return jar.make_cookies(response, request)\n", "path": "scrapy/downloadermiddlewares/cookies.py"}]}