mirror of https://github.com/scrapy/scrapy.git
fix: apply _cookie_value_to_unicode to list-branch cookie key/value
This commit is contained in:
parent
1d965dbc71
commit
c59d32277d
|
|
@ -213,7 +213,7 @@ def request_to_curl(request: Request) -> str:
|
|||
cookie = "; ".join(
|
||||
f"{_cookie_value_to_unicode(c['name'])}={_cookie_value_to_unicode(c['value'])}"
|
||||
if "name" in c and "value" in c
|
||||
else f"{next(iter(c.keys()))}={next(iter(c.values()))}"
|
||||
else f"{_cookie_value_to_unicode(next(iter(c.keys())))}={_cookie_value_to_unicode(next(iter(c.values())))}"
|
||||
for c in request.cookies
|
||||
)
|
||||
cookies = f"--cookie '{cookie}'"
|
||||
|
|
|
|||
|
|
@ -468,3 +468,16 @@ class TestRequestToCurl:
|
|||
" --data-raw '{\"foo\": \"bar\"}' --cookie 'foo=1'"
|
||||
)
|
||||
self._test_request(request_object, expected_curl_command)
|
||||
|
||||
def test_cookies_list_bytes_nonstandard_key(self):
|
||||
request_object = Request(
|
||||
"https://www.httpbin.org/post",
|
||||
method="POST",
|
||||
cookies=[{b"foo": b"bar"}],
|
||||
body=json.dumps({"foo": "bar"}),
|
||||
)
|
||||
expected_curl_command = (
|
||||
"curl -X POST https://www.httpbin.org/post"
|
||||
" --data-raw '{\"foo\": \"bar\"}' --cookie 'foo=bar'"
|
||||
)
|
||||
self._test_request(request_object, expected_curl_command)
|
||||
|
|
|
|||
Loading…
Reference in New Issue