我在发送带有测试请求的 cookie 时遇到了一些问题。我试过这样的事情:
# First request to log in, retrieve cookie from response
response = self.app_client.post('/users/login', query_string={ data.. )
cookie = response.headers['Set-Cookie'] # Contains: user_hash=3f305370487731289a7f9bd8d379a1c2; Domain=.flowdev.com; Path=/
# Second request that requires the cookie
response = self.app_client.get('/users/', headers={'Set-Cookie': cookie})
# Here i print out request.cookies.get('user_hash') inside the app, which contains None
我想这不是那么简单,但我不知道如何在这里以正确的方式构建cookie。应该如何创建第二个请求,以便它沿着标头中的 cookie 发送?
谢谢!