Skip to content
This repository was archived by the owner on Oct 23, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions raven/contrib/django/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@ def get_data_from_request(self, request):
data = request.body
except:
try:
data = request.raw_post_data and request.raw_post_data or request.POST
data = request.raw_post_data
except Exception:
# assume we had a partial read:
data = '<unavailable>'
data = request.POST or '<unavailable>'
else:
data = None

Expand Down
16 changes: 16 additions & 0 deletions tests/contrib/django/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from django.core.urlresolvers import reverse
from django.core.signals import got_request_exception
from django.core.handlers.wsgi import WSGIRequest
from django.http.request import QueryDict
from django.template import TemplateSyntaxError
from django.test import TestCase

Expand Down Expand Up @@ -429,6 +430,21 @@ def test_raw_post_data_partial_read(self):
self.assertEquals(http['method'], 'POST')
self.assertEquals(http['data'], '<unavailable>')

def test_read_post_data(self):
request = make_request()
request.POST = QueryDict("foo=bar&ham=spam")
request.read(1)

self.raven.captureMessage(message='foo', request=request)

self.assertEquals(len(self.raven.events), 1)
event = self.raven.events.pop(0)

self.assertTrue('sentry.interfaces.Http' in event)
http = event['sentry.interfaces.Http']
self.assertEquals(http['method'], 'POST')
self.assertEquals(http['data'], {u'foo': u'bar', u'ham': u'spam'})

# This test only applies to Django 1.3+
def test_request_capture(self):
if django.VERSION[:2] < (1, 3):
Expand Down