Adjusted to use the new Transfer() instead of the old Download()
authorDaniel Stenberg <daniel@haxx.se>
Tue, 1 Feb 2000 23:52:11 +0000 (23:52 +0000)
committerDaniel Stenberg <daniel@haxx.se>
Tue, 1 Feb 2000 23:52:11 +0000 (23:52 +0000)
lib/dict.c
lib/ftp.c
lib/http.c

index e264370..99abf49 100644 (file)
@@ -162,7 +162,8 @@ UrgError dict(struct UrlData *data, char *path, long *bytecount)
           word
           );
     
-    result = Download(data, data->firstsocket, -1, FALSE, bytecount);
+    result = Transfer(data, data->firstsocket, -1, FALSE, bytecount,
+                      -1, NULL); /* no upload */
       
     if(result)
       return result;
@@ -209,7 +210,8 @@ UrgError dict(struct UrlData *data, char *path, long *bytecount)
           word
           );
     
-    result = Download(data, data->firstsocket, -1, FALSE, bytecount);
+    result = Transfer(data, data->firstsocket, -1, FALSE, bytecount,
+                      -1, NULL); /* no upload */
       
     if(result)
       return result;
@@ -232,7 +234,8 @@ UrgError dict(struct UrlData *data, char *path, long *bytecount)
             "QUIT\n",
             ppath);
       
-      result = Download(data, data->firstsocket, -1, FALSE, bytecount);
+      result = Transfer(data, data->firstsocket, -1, FALSE, bytecount,
+                        -1, NULL);
       
       if(result)
         return result;
index fb753f2..e85cc98 100644 (file)
--- a/lib/ftp.c
+++ b/lib/ftp.c
@@ -754,7 +754,8 @@ UrgError _ftp(struct UrlData *data,
        size prior to the actual upload. */
 
     ProgressInit(data, data->infilesize);
-    result = Upload(data, data->secondarysocket, bytecountp);
+    result = Transfer(data, -1, -1, FALSE, NULL, /* no download */
+                      data->secondarysocket, bytecountp);
     if(result)
       return result;
       
@@ -977,8 +978,9 @@ UrgError _ftp(struct UrlData *data,
       infof(data, "Getting file with size: %d\n", size);
 
       /* FTP download: */
-      result=Download(data, data->secondarysocket, size, FALSE,
-                      bytecountp);
+      result=Transfer(data, data->secondarysocket, size, FALSE,
+                      bytecountp,
+                      -1, NULL); /* no upload here */
       if(result)
         return result;
 
index 2dd41c0..49d47b3 100644 (file)
@@ -127,6 +127,8 @@ UrgError http(struct UrlData *data, char *ppath, char *host, long *bytecount)
   struct Cookie *co = NULL;
   char *p_pragma = NULL;
   char *p_accept = NULL;
+  long readbytecount;
+  long writebytecount;
 
   buf = data->buffer; /* this is our buffer */
 
@@ -144,7 +146,7 @@ UrgError http(struct UrlData *data, char *ppath, char *host, long *bytecount)
   
   /* The User-Agent string has been built in url.c already, because it might
      have been used in the proxy connect, but if we have got a header with
-     the user-agent string specified, we erase the previosly made string
+     the user-agent string specified, we erase the previously made string
      here. */
   if(checkheaders(data, "User-Agent:") && data->ptr_uagent) {
     free(data->ptr_uagent);
@@ -315,16 +317,14 @@ UrgError http(struct UrlData *data, char *ppath, char *host, long *bytecount)
               "Content-Length: %d\r\n",
               postsize-2);
        
-        conf = data->conf;
-        data->conf &= ~CONF_NOPROGRESS; /* enable progress meter */
         ProgressInit(data, postsize);
 
-        result = Upload(data, data->firstsocket, bytecount);
+        result = Transfer(data, data->firstsocket, -1, TRUE, &readbytecount,
+                          data->firstsocket, writebytecount);
+        *bytecount = readbytecount + writebytecount;
 
         FormFree(sendit); /* Now free that whole lot */
 
-        data->conf = conf; /* restore conf values for the download */
-          
         if(result)
           return result;
        
@@ -348,27 +348,25 @@ UrgError http(struct UrlData *data, char *ppath, char *host, long *bytecount)
         sendf(data->firstsocket, data,
               "\015\012");
         
-      conf = data->conf;
-      data->conf &= ~CONF_NOPROGRESS; /* enable progress meter */
-
       ProgressInit(data, data->infilesize);
 
-      result = Upload(data, data->firstsocket, bytecount);
-        
-      data->conf = conf;
+      result = Transfer(data, data->firstsocket, -1, TRUE, &readbytecount,
+                        data->firstsocket, &writebytecount);
+      
+      *bytecount = readbytecount + writebytecount;
 
       if(result)
         return result;
 
-      /* reset the byte counter */
-      *bytecount=0;
     }
     else {
       sendf(data->firstsocket, data, "\r\n");
     }
-    /* HTTP GET/HEAD download: */
-    result = Download(data, data->firstsocket, -1, TRUE, bytecount);
-
+    if(0 == *bytecount) {
+      /* HTTP GET/HEAD download: */
+      result = Transfer(data, data->firstsocket, -1, TRUE, bytecount,
+                        -1, NULL); /* nothing to upload */
+    }
     if(result)
       return result;