]> sjero.net Git - wget/blobdiff - src/http.c
[svn] Applied contributed patches (see ChangeLog for details.)
[wget] / src / http.c
index c79e6fecbfe31210f30d3aaf9f3ba7abb0cade0c..3403648a777d1aa0c1cc0e98b057b6b587550c89 100644 (file)
@@ -303,12 +303,14 @@ static time_t http_atotm PARAMS ((char *));
 static uerr_t
 gethttp (struct urlinfo *u, struct http_stat *hs, int *dt)
 {
-  char *request, *type, *command, *path;
+  char *request, *type, *command, *path, *qstring;
   char *user, *passwd;
   char *pragma_h, *referer, *useragent, *range, *wwwauth, *remhost;
   char *authenticate_h;
   char *proxyauth;
   char *all_headers;
+  char *host_port;
+  int host_port_len;
   int sock, hcount, num_written, all_length, remport, statcode;
   long contlen, contrange;
   struct urlinfo *ou;
@@ -382,6 +384,9 @@ gethttp (struct urlinfo *u, struct http_stat *hs, int *dt)
     path = u->proxy->url;
   else
     path = u->path;
+  
+  qstring = u->qstring;
+
   command = (*dt & HEAD_ONLY) ? "HEAD" : "GET";
   referer = NULL;
   if (ou->referer)
@@ -454,10 +459,20 @@ gethttp (struct urlinfo *u, struct http_stat *hs, int *dt)
     }
   remhost = ou->host;
   remport = ou->port;
+
+  if (remport == 80) {
+      host_port = NULL; host_port_len = 0;
+  }
+  else {
+      host_port = (char *)alloca (numdigit (remport) + 2);
+      host_port_len = sprintf (host_port, ":%d", remport);
+  }
+
   /* Allocate the memory for the request.  */
   request = (char *)alloca (strlen (command) + strlen (path)
+                           + (qstring ? strlen (qstring) : 0)
                            + strlen (useragent)
-                           + strlen (remhost) + numdigit (remport)
+                           + strlen (remhost) + host_port_len
                            + strlen (HTTP_ACCEPT)
                            + (referer ? strlen (referer) : 0)
                            + (wwwauth ? strlen (wwwauth) : 0)
@@ -468,18 +483,19 @@ gethttp (struct urlinfo *u, struct http_stat *hs, int *dt)
                            + 64);
   /* Construct the request.  */
   sprintf (request, "\
-%s %s HTTP/1.0\r\n\
+%s %s%s HTTP/1.0\r\n\
 User-Agent: %s\r\n\
-Host: %s:%d\r\n\
+Host: %s%s\r\n\
 Accept: %s\r\n\
 %s%s%s%s%s%s\r\n",
-         command, path, useragent, remhost, remport, HTTP_ACCEPT, 
-         referer ? referer : "", 
-         wwwauth ? wwwauth : "", 
-         proxyauth ? proxyauth : "", 
-         range ? range : "",
-         pragma_h, 
-         opt.user_header ? opt.user_header : "");
+          command, path, qstring ? qstring : "", useragent, remhost,
+          host_port ? host_port : "",
+          HTTP_ACCEPT, referer ? referer : "",
+          wwwauth ? wwwauth : "", 
+          proxyauth ? proxyauth : "", 
+          range ? range : "",
+          pragma_h, 
+          opt.user_header ? opt.user_header : "");
   DEBUGP (("---request begin---\n%s---request end---\n", request));
    /* Free the temporary memory.  */
   FREE_MAYBE (wwwauth);
@@ -942,9 +958,16 @@ File `%s' already there, will not retrieve.\n"), u->local);
       /* Increment the pass counter.  */
       ++count;
       /* Wait before the retrieval (unless this is the very first
-        retrieval).  */
-      if (!first_retrieval && opt.wait)
-       sleep (opt.wait);
+        retrieval).
+        Check if we are retrying or not, wait accordingly - HEH */
+      if (!first_retrieval && (opt.wait || (count && opt.waitretry)))
+       if (count)
+         if (count<opt.waitretry)
+           sleep(count);
+         else
+           sleep(opt.waitretry);
+       else
+         sleep (opt.wait);
       if (first_retrieval)
        first_retrieval = 0;
       /* Get the current time string.  */