]> sjero.net Git - wget/blobdiff - src/retr.c
[svn] Various url.c-related changes.
[wget] / src / retr.c
index 0e4535e8bfdad9a14da72ffb0f5ea9754c45e882..3aae5125324a10b1519e015f8828c0debcb06f63 100644 (file)
@@ -31,7 +31,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 #else
 # include <strings.h>
 #endif /* HAVE_STRING_H */
-#include <ctype.h>
 #include <assert.h>
 
 #include "wget.h"
@@ -55,6 +54,9 @@ LARGE_INTEGER internal_time;
 static long internal_secs, internal_msecs;
 #endif
 
+/* See the comment in gethttp() why this is needed. */
+int global_download_count;
+
 void logflush PARAMS ((void));
 
 /* From http.c.  */
@@ -198,7 +200,8 @@ show_progress (long res, long expected, enum spflags flags)
          print_percentage (nrow * line_bytes + ndot * opt.dot_bytes + offs,
                            expected);
          logprintf (LOG_VERBOSE, " @%s",
-                    rate (ndot * opt.dot_bytes + offs - initial_skip,
+                    rate (ndot * opt.dot_bytes
+                          + offs - (initial_skip % line_bytes),
                           time_offset, 1));
        }
       logputs (LOG_VERBOSE, "\n\n");
@@ -255,7 +258,8 @@ show_progress (long res, long expected, enum spflags flags)
            {
              print_percentage (nrow * line_bytes, expected);
              logprintf (LOG_VERBOSE, " @%s",
-                        rate (line_bytes - initial_skip, time_offset, 1));
+                        rate (line_bytes - (initial_skip % line_bytes),
+                              time_offset, 1));
            }
          initial_skip = 0;
          logprintf (LOG_VERBOSE, "\n%5ldK", nrow * line_bytes / 1024);
@@ -445,11 +449,11 @@ retrieve_url (const char *origurl, char **file, char **newloc,
   assert (u->proto != URLFILE);        /* #### Implement me!  */
   mynewloc = NULL;
 
+  if (u->proto == URLHTTP
 #ifdef HAVE_SSL
-  if (u->proto == URLHTTP || u->proto == URLHTTPS )
-#else
-  if (u->proto == URLHTTP)
-#endif /* HAVE_SSL */
+      || u->proto == URLHTTPS
+#endif
+      )
     result = http_loop (u, &mynewloc, dt);
   else if (u->proto == URLFTP)
     {
@@ -489,7 +493,7 @@ retrieve_url (const char *origurl, char **file, char **newloc,
         redirects, but a ton of boneheaded webservers and CGIs out
         there break the rules and use relative URLs, and popular
         browsers are lenient about this, so wget should be too. */
-      construced_newloc = url_concat (url, mynewloc);
+      construced_newloc = uri_merge (url, mynewloc);
       xfree (mynewloc);
       mynewloc = construced_newloc;
 
@@ -545,6 +549,16 @@ retrieve_url (const char *origurl, char **file, char **newloc,
       goto redirected;
     }
 
+  if (u->local)
+    {
+      if (*dt & RETROKF)
+       {
+         register_download (url, u->local);
+         if (*dt & TEXTHTML)
+           register_html (url, u->local);
+       }
+    }
+
   if (file)
     {
       if (u->local)
@@ -561,6 +575,8 @@ retrieve_url (const char *origurl, char **file, char **newloc,
   else
     xfree (url);
 
+  ++global_download_count;
+
   return result;
 }