Opened 3 years ago

Closed 3 years ago

#15762 closed Bug (duplicate)

WSGIRequest should wrap the test client wsgi.input in LimitedStream

Reported by: tomchristie Owned by: nobody
Component: Testing framework Version: 1.3
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


The following piece of code...


def example_view(request):
    ret = 'started read\n'
    buffer =
    while buffer:
        ret += 'read %d bytes\n' % len(buffer)
        buffer =
	ret += 'finished read\n'
    return HttpResponse(ret)

works fine under each of these cases...

  • django trunk (1.3.0) / apache + mod_wsgi 3.2
  • django trunk (1.3.0) / apache + mod_python 3.3.1
  • django trunk (1.3.0) / development server

(Eg responds correctly both to GET requests and to PUT requests with content)

but fails when run with the test client, with:

AssertionError: Cannot read more than the available bytes from the HTTP incoming data.

It looks to me like WSGIRequest ought to wrap the test client wsgi.input stream in a LimitedStream wrapped in that same way that it would do for the development server.

Patch and test are attached.

Attachments (1)

patch_test_client_wsgi_input.diff (3.7 KB) - added by tomchristie 3 years ago.
Ensure test client wsgi.input is wrapped in LimitedStream

Download all attachments as: .zip

Change History (2)

Changed 3 years ago by tomchristie

Ensure test client wsgi.input is wrapped in LimitedStream

comment:1 Changed 3 years ago by tomchristie

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to duplicate
  • Status changed from new to closed

See #15785 for fixing the underlying problem.

Add Comment

Modify Ticket

Change Properties
<Author field>
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'

E-mail address and user name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.