]> sjero.net Git - wget/blobdiff - src/http.c
On a network error, attempt to resume the download, not restart it.
[wget] / src / http.c
index 6d9b1e9b70c88c65973153d93e07f2d401962abf..99f58b3f1a9d3ea69e312c495437eb34cbe2e3dd 100644 (file)
@@ -927,17 +927,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 +1494,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;
 
@@ -2473,7 +2468,7 @@ File %s already there; not retrieving.\n\n"), quote (hs->local_file));
       mkalldirs (hs->local_file);
       if (opt.backups)
         rotate_backups (hs->local_file);
-      if (hs->restval)
+      if (hs->restval || count > 0)
         {
 #ifdef __VMS
           int open_id;
@@ -2761,7 +2756,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 +3131,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);