Index: lib/sendf.c
===================================================================
RCS file: /repository/curl/lib/sendf.c,v
retrieving revision 1.74
diff -u -r1.74 sendf.c
--- lib/sendf.c	29 Jan 2004 13:56:45 -0000	1.74
+++ lib/sendf.c	29 Jan 2004 22:26:31 -0000
@@ -420,6 +420,7 @@
 
     if(-1 == nread) {
       int err = Curl_ourerrno();
+      conn->sockerror = err;
 #ifdef WIN32
       if(WSAEWOULDBLOCK == err)
 #else
Index: lib/transfer.c
===================================================================
RCS file: /repository/curl/lib/transfer.c,v
retrieving revision 1.195
diff -u -r1.195 transfer.c
--- lib/transfer.c	28 Jan 2004 17:07:22 -0000	1.195
+++ lib/transfer.c	29 Jan 2004 22:26:31 -0000
@@ -1896,12 +1896,25 @@
 
       if(res == CURLE_OK) {
         res = Transfer(conn); /* now fetch that URL please */
-        if(res == CURLE_OK)
+        if(res == CURLE_OK) {
+
+          if((conn->keep.bytecount == 0) &&
+             (conn->sockerror == ECONNRESET) &&
+             conn->bits.reuse) {
+            /* We got no data, the connection was reset and we did attempt
+               to re-use a connection. This smells like we were too fast to
+               re-use a connection that was closed when we wanted to read
+               from it. Bad luck. Let's simulate a redirect to the same URL
+               to retry! */
+            conn->newurl = strdup(conn->data->change.url);
+          }
+
           /*
            * We must duplicate the new URL here as the connection data
            * may be free()ed in the Curl_done() function.
            */
           newurl = conn->newurl?strdup(conn->newurl):NULL;
+        }
         else {
           /* The transfer phase returned error, we mark the connection to get
            * closed to prevent being re-used. This is becasue we can't
Index: lib/urldata.h
===================================================================
RCS file: /repository/curl/lib/urldata.h,v
retrieving revision 1.191
diff -u -r1.191 urldata.h
--- lib/urldata.h	22 Jan 2004 12:45:50 -0000	1.191
+++ lib/urldata.h	29 Jan 2004 22:26:32 -0000
@@ -563,6 +563,8 @@
                                single requests! */
   struct ntlmdata proxyntlm; /* NTLM data for proxy */
 
+  int sockerror; /* errno stored by Curl_read() if the underlying layer returns
+                    error */
 #ifdef USE_ARES
   /* data used for the asynch name resolve callback */
   struct Curl_async async;
