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

81 views
Skip to first unread message

knabar

unread,
Mar 27, 2012, 10:34:16 AM3/27/12
to PyISAPIe
[I apologize for posting this in multiple places, I just put it up on
stackoverflow and then realized it should have gone here first.]

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 first 16kB block of POST data are correct
* The next 16kB block is a repeat of the first block
* The next 16kB is another repeat of the first block
* The rest (<16kB) is correct again

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!

knabar

unread,
Mar 27, 2012, 11:42:35 AM3/27/12
to PyISAPIe
I think I found the bug, not sure how to fix it though:

http://stackoverflow.com/questions/9891467/large-post-data-is-corrupted-when-using-django-pyisapie-iis

Perhaps somebody with more experience with PyISAPIe and C can verify?

Thank you,

Andreas

Phillip Sitbon

unread,
Mar 28, 2012, 1:27:19 AM3/28/12
to pyis...@googlegroups.com
Hi Andreas-

Your analysis is correct -- it looks like this bug got fixed in SVN
but wasn't part of the latest release
(http://sourceforge.net/apps/trac/pyisapie/ticket/7), so for now I'll
direct you to the repository where it's been addressed and roll out
what I believe to be a stable version.

A lot of people have been using the repo for some time now and so it's
allowed me to be far too lazy about packaging releases... I think it's
time to remedy that.

Cheers,
Phillip

> --
> You received this message because you are subscribed to the Google Groups "PyISAPIe" group.
> To post to this group, send email to pyis...@googlegroups.com.
> To unsubscribe from this group, send email to pyisapie+u...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/pyisapie?hl=en.
>

Andreas Knab

unread,
Mar 28, 2012, 9:54:48 AM3/28/12
to pyis...@googlegroups.com
Thanks - I was not aware there were additional changes in the
repository. I'll give it a try, I have not tried compiling it myself
before.

Andreas

Reply all
Reply to author
Forward
0 new messages