﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
14753	Accessing (Get)HttpRequest.raw_post_data in view results in exception during testing	Piotr Czachur	nobody	"(Confirmed with Django trunk r14680)

This happens only when running tests and test client makes GET request.
When views is accessed under runserver, it serves empty page as desired - no exception is raised.

{{{
# view
def zoo(response):
    return HttpResponse(response.raw_post_data)
}}}

{{{
#view test
class SimpleTest(TestCase):    
    def test_lala(self):       
        c = Client()
        res = c.get('/')
}}}

{{{
/tmp/zoo$ time python manage.py test --failfast
Creating test database for alias 'default'...
F
======================================================================
FAIL: test_lala (zoo.lew.tests.SimpleTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File ""/tmp/zoo/../zoo/lew/tests.py"", line 15, in test_lala
    res = c.get('/')
  File ""/tmp/zoo/django/test/client.py"", line 434, in get
    response = super(Client, self).get(path, data=data, **extra)
  File ""/tmp/zoo/django/test/client.py"", line 218, in get
    return self.request(**r)
  File ""/tmp/zoo/django/core/handlers/base.py"", line 109, in get_response
    response = callback(request, *callback_args, **callback_kwargs)
  File ""/tmp/zoo/../zoo/lew/views.py"", line 6, in zoo
    return HttpResponse(re.raw_post_data)
  File ""/tmp/zoo/django/http/__init__.py"", line 153, in _get_raw_post_data
    self._raw_post_data = self.read()
  File ""/tmp/zoo/django/http/__init__.py"", line 199, in read
    return self._stream.read(*args, **kwargs)
  File ""/tmp/zoo/django/test/client.py"", line 50, in read
    assert self.__len >= num_bytes, ""Cannot read more than the available bytes from the HTTP incoming data.""
AssertionError: Cannot read more than the available bytes from the HTTP incoming data.
}}}

I can agree that accessing raw_post_data in case of GET request is weird, but nevertheless such issue should be handled in consistent way no matter if it's request via Django's test client or real http request handled by runserver.

"		closed	Testing framework	dev		fixed	blocker		Accepted	1	0	0	0	0	0
