Damian Cugley’s Weblog
So far getting uploads to work with the Picky Picky Game is an uphill struggle. Some web browsers work and some do not, and it is going to require some fancy diagnostic tools to find out why not.
Safari works fine, except when it doesn’t. I often get an alert saying the request failed ‘because the network connection was reset. This sometimes occurs when the server is busy.’ Apparently I am not the only one—I found a reference to this message on a O’Reilly network message board. If I try the request again it usually works the second time.
If, however, I was trying to submit a form, and the form had
method="post"
and
enctype="multipart/form-data"
, then
some weird things happen.
First of all, although what I see is the filled-in form,
I cannot
repeat the request by clicking on the Submit button—it
does nothing. If I click on the Reload button (which I would
have expected to reload the form, not resubmit it), then the
form is submitted again, but! my CGI script sees
REQUEST_METHOD="GET"
(as opposed to
POST
). Since my script distinguishes between
these two verbs, it fails with a 404 error code.
I believe these behaviours might be bugs.
I have also tried Microsoft Internet Explorer (Mac OS X version). When I submit a form with an uploaded file it simply spins forever—it apparently never finishes the upload.
I also installed Camino, a Gecko +
Cocoa browser. When I try to submit the upload form I see the
‘barber pole’ progress indicator for a long while,
then it displays an error message from my CGI script indicating
it was interrupted by the server (thttpd
) for taking
too long.
All three mentioned above are running on my shiny new PowerBook
12″, running Mac OS X version 10.2.5,
connecting to my thttpd
server over Ethernet.
I have also tried Microsoft Internet Explorer 5½ running on Windows NT 4.0. It exhibits the same behaviour as Camino. This was the bug that I discussed a while back, where the script gets wedged reading the data uploaded by its caller.
Meanwhile things work fine on my Linux box—at least with Opera 5, which is the most recent web browser I have installed thereon (my Red Hat 6.2 installation is too primitive for more modern browsers).
Apart from some arguably buggy behaviour from Safari, presumably
there are nuances about the way these various programs interpret
the rules for submitting forms that are foxing my CGI script.
Obviously I have tried using a script that simply
regurgitates what it reads, but the various infinite-pause
behaviours happen while it is reading in the
data—and if it cannot get that far then there is not
much for it to report... I need to write some sort of
fiendishly clever one-byte-at-a-time system that is somehow
clever enough not to be fooled by lying
Content-length
headers or transitory network
problems. Or line endings, though I thought I had carefully
taken line-ending variations in to account. Sigh.
Update: After adding some xtra instrumentation to my CGI script, it appears that when the request is from MSIE it receives 1408 bytes or so, from Camino 1344 bytes or so. I begin to suspect a dodgy network stack on my creaky Linux box—I am tempted to believe those numbers could represent a 1500-byte packet minus the header info...
Also, now I have installed the application on a different web server, and the uplaoding of files appears to happen without a hitch—it then fails to save them to disc because Apache is running as a user with insifficuent privs to create the directory. But at least the upload works!