]> sjero.net Git - wget/blobdiff - src/http.c
mass change: update copyright years.
[wget] / src / http.c
index 6d9b1e9b70c88c65973153d93e07f2d401962abf..142b9219442a8c5f2888ac8bea9edb76910786d0 100644 (file)
@@ -1,6 +1,7 @@
 /* HTTP support.
    Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
-   2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+   2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation,
+   Inc.
 
 This file is part of GNU Wget.
 
@@ -33,9 +34,7 @@ as that of the covered work.  */
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#ifdef HAVE_UNISTD_H
-# include <unistd.h>
-#endif
+#include <unistd.h>
 #include <assert.h>
 #include <errno.h>
 #include <time.h>
@@ -927,17 +926,12 @@ skip_short_body (int fd, wgint contlen, bool chunked)
               char *line = fd_read_line (fd);
               char *endl;
               if (line == NULL)
-                {
-                  ret = -1;
-                  break;
-                }
+                break;
 
               remaining_chunk_size = strtol (line, &endl, 16);
               if (remaining_chunk_size == 0)
                 {
-                  ret = 0;
-                  if (fd_read_line (fd) == NULL)
-                    ret = -1;
+                  fd_read_line (fd);
                   break;
                 }
             }
@@ -1499,7 +1493,7 @@ free_hstat (struct http_stat *hs)
    server, and u->url will be requested.  */
 static uerr_t
 gethttp (struct url *u, struct http_stat *hs, int *dt, struct url *proxy,
-         struct iri *iri)
+         struct iri *iri, int count)
 {
   struct request *req;
 
@@ -2484,7 +2478,7 @@ File %s already there; not retrieving.\n\n"), quote (hs->local_file));
           fp = fopen (hs->local_file, "ab");
 #endif /* def __VMS [else] */
         }
-      else if (ALLOW_CLOBBER)
+      else if (ALLOW_CLOBBER || count > 0)
         {
          if (opt.unlink && file_exists_p (hs->local_file))
            {
@@ -2761,7 +2755,7 @@ Spider mode enabled. Check if remote file exists.\n"));
         *dt &= ~SEND_NOCACHE;
 
       /* Try fetching the document, or at least its head.  */
-      err = gethttp (u, &hstat, dt, proxy, iri);
+      err = gethttp (u, &hstat, dt, proxy, iri, count);
 
       /* Time?  */
       tms = datetime_str (time (NULL));
@@ -3136,7 +3130,7 @@ Remote file exists.\n\n"));
   while (!opt.ntry || (count < opt.ntry));
 
 exit:
-  if (ret == RETROK)
+  if (ret == RETROK && local_file)
     *local_file = xstrdup (hstat.local_file);
   free_hstat (&hstat);