Skip to content

Commit 7c3f98d

Browse files
committed
fix: Extract Tornados cookies correctly, fix #276
1 parent 56d5a2c commit 7c3f98d

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

sentry_sdk/integrations/tornado.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ def content_length(self):
165165

166166
def cookies(self):
167167
# type: () -> Dict
168-
return dict(self.request.cookies)
168+
return {k: v.value for k, v in self.request.cookies.items()}
169169

170170
def raw_data(self):
171171
# type: () -> bytes

tests/integrations/tornado/test_tornado.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,17 @@ def get(self):
1818
class TestBasic(AsyncHTTPTestCase):
1919
@pytest.fixture(autouse=True)
2020
def initialize(self, sentry_init, capture_events):
21-
sentry_init(integrations=[TornadoIntegration()])
21+
sentry_init(integrations=[TornadoIntegration()], send_default_pii=True)
2222
self.events = capture_events()
2323

2424
def get_app(self):
2525

2626
return Application([(r"/hi", CrashingHandler)])
2727

2828
def test_basic(self):
29-
response = self.fetch("/hi?foo=bar")
29+
response = self.fetch(
30+
"/hi?foo=bar", headers={"Cookie": "name=value; name2=value2; name3=value3"}
31+
)
3032
assert response.code == 500
3133

3234
event, = self.events
@@ -37,7 +39,13 @@ def test_basic(self):
3739
host = request["headers"]["Host"]
3840
assert event["request"] == {
3941
"env": {"REMOTE_ADDR": "127.0.0.1"},
40-
"headers": {"Accept-Encoding": "gzip", "Connection": "close", "Host": host},
42+
"headers": {
43+
"Accept-Encoding": "gzip",
44+
"Connection": "close",
45+
"Host": host,
46+
"Cookie": "name=value; name2=value2; name3=value3",
47+
},
48+
"cookies": {"name": "value", "name2": "value2", "name3": "value3"},
4149
"method": "GET",
4250
"query_string": "foo=bar",
4351
"url": "http://{host}/hi".format(host=host),

0 commit comments

Comments
 (0)