pythoncdjangopython-c-apipyisapie

Large POST data is corrupted when using Django/PyISAPIe/IIS


I'm running into a problem with large POST data (>16384 bytes) when using Django 1.2.3, PyISAPIe v1.1.0-rc4, and IIS 7.5.

For example, when submitting approx. 60kB of form data using POST, the following happens:

The interesting part is that when using content-type="multipart/form-data", it works fine.

Using this information I tracked down the likely location of the bug to WSGIRequest._get_raw_post_data in django\core\handlers\wsgi.py, which handles the content-type="multipart/form-data" separately from the default (no content-type) case.

Both cases read from self.environ['wsgi.input'], which is set to the PyISAPIe object. The difference is that the default case seems to read in chunks of 16kB, whereas the multipart handler seems to read in chunks of just under 2GB.

I don't know enough about C and the Python interface for C to dig in further, but I'm guessing the bug is somewhere in PyISAPIe in the ReadClient function in ReadWrite.cpp.

My current workaround is to add content-type="multipart/form-data" to forms that may product more than 16kB of data.

Has anybody run into this as well, or does anybody know how to determine if the bug is in fact in PyISAPIe?

Thank you!


Solution

  • PyISAPIe author here.

    This was fixed in revision 184 in the repository but not in the downloadable release, as discussed on the mailing list.

    It addressed a previously documented bug that apparently hasn't received much attention because many users are checking out the source rather than downloading the package. Or, that's my best guess anyway; regardless, I plan to provide a downloadable version of the fixed code.

    Thanks for bringing this to my attention so I can be reminded to keep this project's releases in a functioning state.