Opened 14 years ago

Closed 14 years ago

#15762 closed Bug (duplicate)

WSGIRequest should wrap the test client wsgi.input in LimitedStream

Reported by: Tom Christie 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: no UI/UX: no

Description

The following piece of code...

BUFFER_SIZE = 16000

def example_view(request):
    ret = 'started read\n'
    buffer = request.read(BUFFER_SIZE)
    while buffer:
        ret += 'read %d bytes\n' % len(buffer)
        buffer = request.read(BUFFER_SIZE)
	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 Tom Christie 14 years ago.
Ensure test client wsgi.input is wrapped in LimitedStream

Download all attachments as: .zip

Change History (2)

by Tom Christie, 14 years ago

Ensure test client wsgi.input is wrapped in LimitedStream

comment:1 by Tom Christie, 14 years ago

Resolution: duplicate
Status: newclosed

See #15785 for fixing the underlying problem.

Note: See TracTickets for help on using tickets.
Back to Top