|
Harold J. Ship
Harold at giant-steps-networks.com
Wed Apr 5 02:51:57 EDT 2006
Attempting to upload a file using Flash 8 FileReference.upload(url)
causes a ValueError at line 173 of util.py.
Windows XP
Apache 2.0.54
mod_python 3.2.8
>From httpd.conf:
<VirtualHost *:8020>
ServerName python
DocumentRoot "c:/Program Files/Apache Group/Apache2/htdocs/python"
<Directory "c:/Program Files/Apache Group/Apache2/htdocs/python">
AddHandler mod_python .py
PythonHandler deko_publisher
PythonDebug Off
RewriteEngine On
RewriteRule ^$ ^$ [F]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(\w+)/(.*)$ $1.py/$2 [QSA,L]
ErrorDocument 500 "<h2>Application error</h2>Problem with Python
Setup"
</Directory>
</VirtualHost>
deko_publisher is my own handler that delegates to mod_python.publisher
It seems that the HTTP request has some header lines that aren't of the
form "Name: value" such as file boundaries.
>From error.log:
[Mon Apr 03 12:05:40 2006] [INFO] WebPython deko_publisher.py:17 about
to run uploadFoo
[Mon Apr 03 12:05:40 2006] [error] [client 127.0.0.1] PythonHandler
deko_publisher: Traceback (most recent call last):
[Mon Apr 03 12:05:40 2006] [error] [client 127.0.0.1] PythonHandler
deko_publisher: File
"C:\\Python23\\Lib\\site-packages\\mod_python\\apache.py", line 299, in
HandlerDispatch\n result = object(req)
[Mon Apr 03 12:05:41 2006] [error] [client 127.0.0.1] PythonHandler
deko_publisher: File "C:/Program Files/Apache
Group/Apache2/htdocs/python/deko_publisher.py", line 18, in handler\n
return apache.handler(req)
[Mon Apr 03 12:05:41 2006] [error] [client 127.0.0.1] PythonHandler
deko_publisher: File
"C:\\Python23\\Lib\\site-packages\\mod_python\\publisher.py", line 213,
in handler\n published = publish_object(req, object)
[Mon Apr 03 12:05:41 2006] [error] [client 127.0.0.1] PythonHandler
deko_publisher: File
"C:\\Python23\\Lib\\site-packages\\mod_python\\publisher.py", line 411,
in publish_object\n req.form = util.FieldStorage(req,
keep_blank_values=1)
[Mon Apr 03 12:05:41 2006] [error] [client 127.0.0.1] PythonHandler
deko_publisher: File
"C:\\Python23\\Lib\\site-packages\\mod_python\\util.py", line 173, in
__init__\n h, v = line.split(":", 1)
[Mon Apr 03 12:05:41 2006] [error] [client 127.0.0.1] PythonHandler
deko_publisher: ValueError: unpack list of wrong size
util.py (lines 169-175):
while line not in ('\r','\r\n'):
# we read the headers until we reach an empty line
# NOTE : a single \n would mean the entity is malformed,
but
# we're tolerating it anyway
h, v = line.split(":", 1)
headers.add(h, v)
h = h.lower()
proposed change:
while line not in ('\r','\r\n'):
# we read the headers until we reach an empty line
# NOTE : a single \n would mean the entity is malformed,
but
# we're tolerating it anyway
try:
h, v = line.split(":", 1)
except ValueError:
h, v = "", ""
headers.add(h, v)
h = h.lower()
Harold Ship
Giant Steps Networks
|