TCP connections and Safari form file upload
TCP connections and Safari form file upload
- Subject: TCP connections and Safari form file upload
- From: Eric Rath <email@hidden>
- Date: Wed, 13 Dec 2006 13:01:57 -0800
Hi,
I posted this the web-dev list, and someone suggested I post here
instead. File upload via a plain vanilla HTML form occasionally
fails in Safari v. 2.0.4 (419.3) when posting to a server using
Apache's httpd (2.0.x or 2.2.x) with KeepAlive enabled. I've never
seen this particular problem when using other browsers (Firefox on
10.4.x, IE 5/6/7 on Win). After using tshark to monitor the traffic
between the client and the server, I know how to reproduce the problem:
1. User clicks link to form; client requests page with form; this
includes client establishing connection with SYN--SYN,ACK--ACK
handshake with server, and then sending HTTP GET.
2. Server sends HTTP response.
3. Client sends ACK.
4. After the server's KeepAlive timeout elapses, server sends client
ACK,FIN.
5. Client sends ACK.
6. User selects file, submits form; client sends HTTP POST (includes
other form data, *not* anything about file).
7. Client sends another HTTP POST (includes filename and file length)
8. Server sends RESET.
9. Client sends SYN.
10. Server sends SYN,ACK.
11. Client sends ACK.
12. Client sends HTTP POST (includes other form data, *not* anything
about file), basically repeating step 6.
13. Client sends another HTTP POST (includes filename and file
length), repeating step 7.
14. Server sends ACK
15. Server sends another ACK
Then the client goes silent, and does *NOT* send the actual file
data. The key to reproducing the problem is to wait until the server
closes its half of the connection in step 4. If you send before
that, it works fine (Safari sends the file data). If instead you
wait long enough, Safari closes *its* half of the connection, too,
and it works fine (presumably because Safari starts from scratch and
reestablishes the connection). The problem only occurs if the POST
is sent between the two closures; Safari --or the server-- seems to
get tripped up.
I know I can fix the problem by configuring the server to disable
KeepAlive for Safari clients, but is there a better workaround or
solution? I can't rule out the possibility that I'm doing something
wrong, but I can't think of what it could be. The html form in
question is *very* basic; no AJAX or other Javascript involved:
<form name="foo" action="http://www.example.com/form" method="post">
<input type="file" name="theFile" />
<input type="submit" name="submit" value="upload" />
</form>
I've reproduced the problem using the same client and against the
same HTML form on three different servers: one runs Mac OS 10.4
server and httpd 2.2.1, and the other two run SuSE 9.2 and httpd
2.0.59. The behavior doesn't vary between servers (other than the
duration of the KeepAliveTimeout value in the httpd configuration).
I checked the behavior of Firefox (1.5.0.8) on Mac OS X against the
same server (the one running SuSE 9.2 and httpd 2.0.59), and found
that the KeepAlive functioned the same way; after KeepAliveTimeout
had elapsed, the server closed its side of the connection, and if
left alone awhile after that Firefox closed its side of the
connection. If the form was submitted while the connection was half-
closed, Firefox closed its connection (with ACK,FIN, even though its
side of the connection was still open), and reopened (with the SYN--
ACK,SYN--ACK handshake) before proceeding with the HTTP POST. As
mentioned before, I've never had the problem with Firefox, so this
closing and reopening of the connection seems to prevent the problem
from happening.
Thanks for any feedback or advice,
Eric
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden