From b84eaff1d57754e9d154fa7fc7bf941c9e430a31 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 2 Feb 2004 14:49:54 +0000 Subject: set the 'retry' bit to TRUE when the connection is about to be retried, this allows the HTTP code to *not* return a failure just because no data has been received from the server --- lib/http.c | 8 +++++--- lib/if2ip.c | 2 ++ lib/transfer.c | 11 +++++++++++ lib/urldata.h | 2 ++ 4 files changed, 20 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/http.c b/lib/http.c index fea11f59a..3bab60df3 100644 --- a/lib/http.c +++ b/lib/http.c @@ -1028,9 +1028,11 @@ CURLcode Curl_http_done(struct connectdata *conn) else if(HTTPREQ_PUT == data->set.httpreq) conn->bytecount = http->readbytecount + http->writebytecount; - if(0 == (http->readbytecount + conn->headerbytecount)) { - /* nothing was read from the HTTP server, this can't be right - so we return an error here */ + if(!conn->bits.retry && + !(http->readbytecount + conn->headerbytecount)) { + /* If this connection isn't simply closed to be retried, AND nothing was + read from the HTTP server, this can't be right so we return an error + here */ failf(data, "Empty reply from server"); return CURLE_GOT_NOTHING; } diff --git a/lib/if2ip.c b/lib/if2ip.c index 0dd403ac9..299be75dd 100644 --- a/lib/if2ip.c +++ b/lib/if2ip.c @@ -51,7 +51,9 @@ #ifdef HAVE_NET_IF_H #include #endif +#ifdef HAVE_SYS_IOCTL_H #include +#endif /* -- if2ip() -- */ #ifdef HAVE_NETDB_H diff --git a/lib/transfer.c b/lib/transfer.c index ac23b11c8..707895fde 100644 --- a/lib/transfer.c +++ b/lib/transfer.c @@ -29,7 +29,9 @@ #include #include #include +#ifdef HAVE_SYS_TYPES_H #include +#endif #include #include @@ -44,7 +46,9 @@ #ifdef HAVE_SYS_SOCKET_H #include #endif +#ifdef HAVE_NETINET_IN_H #include +#endif #include #ifdef HAVE_UNISTD_H #include @@ -56,7 +60,9 @@ #ifdef HAVE_NET_IF_H #include #endif +#ifdef HAVE_SYS_IOCTL_H #include +#endif #include #ifdef HAVE_SYS_PARAM_H @@ -1910,6 +1916,11 @@ CURLcode Curl_perform(struct SessionHandle *data) newurl = strdup(conn->data->change.url); conn->bits.close = TRUE; /* close this connection */ + conn->bits.retry = TRUE; /* mark this as a connection we're about + to retry. Marking it this way should + prevent i.e HTTP transfers to return + error just because nothing has been + transfered! */ } else /* diff --git a/lib/urldata.h b/lib/urldata.h index 49a38dfb2..9b81e69a6 100644 --- a/lib/urldata.h +++ b/lib/urldata.h @@ -296,6 +296,8 @@ struct ConnectBits { bool tcpconnect; /* the tcp stream (or simimlar) is connected, this is set the first time on the first connect function call */ + bool retry; /* this connection is about to get closed and then + re-attempted at another connection. */ }; /* -- cgit v1.2.3