Apache Server configuration support - Truncated file uploads with Python/CGI/Apache/Windows

This is Interesting: Free IT Magazines  
Home > Archive > Apache Server configuration support > December 2007 > Truncated file uploads with Python/CGI/Apache/Windows





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Truncated file uploads with Python/CGI/Apache/Windows
Cameron Walsh

2007-12-10, 7:37 am

Hi all,

When uploading a file from a form with enctype="multipart/form-data" to
a Python cgi script on an Windows/Apache server, the file seems to get
truncated after a few kilobytes, the exact limit depending on which file
was uploaded.

No errors appear in the apache logs.

A few days ago I was able to find an apache config directive to fix this
problem, I believe it had the word "buffer" in it, but I have since lost
this fix and somewhat embarrassingly I have been unable to find it again
despite half an hour of google.

Could somebody point me in the right direction?

Best regards,

Cameron.
HansH

2007-12-10, 1:26 pm

"Cameron Walsh" <cameron.walsh@gmail.com> schreef in bericht
news:475d2487$0$25519$5a62ac22@per-qv1-newsreader-01.iinet.net.au...
> When uploading a file from a form with enctype="multipart/form-data" to a
> Python cgi script on an Windows/Apache server, the file seems to get
> truncated after a few kilobytes, the exact limit depending on which file
> was uploaded.
>
> No errors appear in the apache logs.
>
> A few days ago I was able to find an apache config directive to fix this
> problem, I believe it had the word "buffer" in it, but I have since lost
> this fix and somewhat embarrassingly I have been unable to find it again
> despite half an hour of google.
>

On Windows I'ld try for wathever reason
http://httpd.apache.org/docs/2.2/mo...disableacceptex

Given the discrived troubles try [not] using
http://httpd.apache.org/docs/2.2/mo...imitrequestbody


Next option: make a choice at
http://httpd.apache.org/docs/2.2/mod/directives.html



HansH


Cameron Walsh

2007-12-11, 7:37 am

HansH wrote:
> "Cameron Walsh" <cameron.walsh@gmail.com> schreef in bericht
> news:475d2487$0$25519$5a62ac22@per-qv1-newsreader-01.iinet.net.au...
> On Windows I'ld try for wathever reason
> http://httpd.apache.org/docs/2.2/mo...disableacceptex
>
> Given the discrived troubles try [not] using
> http://httpd.apache.org/docs/2.2/mo...imitrequestbody
>
>
> Next option: make a choice at
> http://httpd.apache.org/docs/2.2/mod/directives.html
>
>
>
> HansH
>
>

Hi Hans,

I tried win32disableacceptex, and EnableSendfile Off, EnableMMAP Off
since they have been recommended for windows systems in the past. None
of them helped.

limitrequestbody 0 and 20000 and 20000000 didn't help either.

I've looked through the directives, trying different values for
ReceiveBufferSize (0 and 20000000) didn't change anything.

I've noticed that it only truncates binary files, not text files. I
assume it's hitting some byte that causes it to believe it's the end of
the file? Specifically .png files are being truncated straight after
the bytes "PNG" in the header of the image. Any ideas?

In the mean time I'll keep trying different directives.

Thanks and regards,

Cameron.
HansH

2007-12-11, 1:26 pm

"Cameron Walsh" <cameron.walsh@gmail.com> schreef in bericht
news:475e8c5b$0$25543$5a62ac22@per-qv1-newsreader-01.iinet.net.au...
> I tried win32disableacceptex, and EnableSendfile Off, EnableMMAP Off since
> they have been recommended for windows systems in the past. None of them
> helped.
>
> I've noticed that it only truncates binary files, not text files. I
> assume it's hitting some byte that causes it to believe it's the end of
> the file?

That seem to be the (in)famous ^Z or \x1A, and unreleated to apache btw.

> Specifically .png files are being truncated straight after the bytes "PNG"
> in the header of the image. Any ideas?

Within your program handle the i/o as a series of bytes rather than
character.

HansH


Cameron Walsh

2007-12-12, 7:36 am

HansH wrote:
> "Cameron Walsh" <cameron.walsh@gmail.com> schreef in bericht
> news:475e8c5b$0$25543$5a62ac22@per-qv1-newsreader-01.iinet.net.au...
> That seem to be the (in)famous ^Z or \x1A, and unreleated to apache btw.
>
> Within your program handle the i/o as a series of bytes rather than
> character.
>
> HansH
>
>


Hi Hans,

You picked the error correctly, it is indeed unrelated to Apache, but
Apache can be used to fix it. The trick was the directive:

SetEnv PYTHONUNBUFFERED 1

Thanks and best regards,

Cameron.
HansH

2007-12-12, 7:24 pm

"Cameron Walsh" <cameron.walsh@gmail.com> schreef in bericht
news:475fcac4$0$25529$5a62ac22@per-qv1-newsreader-01.iinet.net.au...
> HansH wrote:
> You picked the error correctly, it is indeed unrelated to Apache, but
> Apache can be used to fix it. The trick was the directive:
>
> SetEnv PYTHONUNBUFFERED 1
>

That [sh|c]ould have been set as a system var under
this computer>properties>advanced>env vars

Not into Python at all, the relation between name and function of this
parameter surprices me.

Unbuffered output may have serious performance drawbacks in many scenarioes.
Setting this might cause your programs to sent vai apache its output to a
browser in a multitude of small packets each with only a small payload
rather than a few packets of about 1.5kByte each, raising network overhead
from below 5 to potentionally over 50%.


HansH


Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com