? Makefile
? .deps
? Makefile.in
? file.lo
? timeval.lo
? base64.lo
? hostip.lo
? progress.lo
? formdata.lo
? cookie.lo
? http.lo
? sendf.lo
? ftp.lo
? url.lo
? dict.lo
? if2ip.lo
? speedcheck.lo
? getdate.lo
? ldap.lo
? ssluse.lo
? version.lo
? getenv.lo
? diffs
? escape.lo
? mprintf.lo
? telnet.lo
? getpass.lo
? formdata
? netrc.lo
? getinfo.lo
? transfer.lo
? strequal.lo
? easy.lo
? security.lo
? krb4.lo
? memdebug.lo
? .libs
? libcurl.la
? progress.diff
? memdump
? hostip.c.org
? put_resume.patch
Index: http.c
===================================================================
RCS file: /cvsroot/curl/lib/http.c,v
retrieving revision 1.42
diff -u -r1.42 http.c
--- http.c	2001/01/25 12:19:02	1.42
+++ http.c	2001/01/26 15:33:16
@@ -471,6 +471,64 @@
   if(!checkheaders(data, "Accept:"))
     http->p_accept = "Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*\r\n";
 
+  if((data->bits.http_post ||
+      data->bits.http_formpost ||
+      data->bits.http_put) &&
+     data->resume_from) {
+    /**********************************************************************
+     * Resuming upload in HTTP means that we PUT or POST and that we have
+     * got a resume_from value set. The resume value has already created
+     * a Range: header that will be passed along. We need to "fast forward"
+     * the file the given number of bytes and decrease the assume upload
+     * file size before we continue this venture in the dark lands of HTTP.
+     *********************************************************************/
+   
+    if(data->resume_from < 0 ) {
+      /*
+       * This is meant to get the size of the present remote-file by itself.
+       * We don't support this now. Bail out!
+       */
+       data->resume_from = 0;
+    }
+
+    if(data->resume_from) {
+      /* do we still game? */
+      int passed=0;
+
+      /* Now, let's read off the proper amount of bytes from the
+         input. If we knew it was a proper file we could've just
+         fseek()ed but we only have a stream here */
+      do {
+        int readthisamountnow = (data->resume_from - passed);
+        int actuallyread;
+
+        if(readthisamountnow > BUFSIZE)
+          readthisamountnow = BUFSIZE;
+
+        actuallyread =
+          data->fread(data->buffer, 1, readthisamountnow, data->in);
+
+        passed += actuallyread;
+        if(actuallyread != readthisamountnow) {
+          failf(data, "Could only read %d bytes from the input\n",
+                passed);
+          return CURLE_READ_ERROR;
+        }
+      } while(passed != data->resume_from); /* loop until done */
+
+      /* now, decrease the size of the read */
+      if(data->infilesize>0) {
+        data->infilesize -= data->resume_from;
+
+        if(data->infilesize <= 0) {
+          failf(data, "File already completely uploaded\n");
+          return CURLE_PARTIAL_FILE;
+        }
+      }
+      /* we've passed, proceed as normal */
+    }
+  }
+
   do {
     send_buffer *req_buffer;
     struct curl_slist *headers=data->headers;
Index: transfer.c
===================================================================
RCS file: /cvsroot/curl/lib/transfer.c,v
retrieving revision 1.3
diff -u -r1.3 transfer.c
--- transfer.c	2001/01/25 12:23:12	1.3
+++ transfer.c	2001/01/26 15:33:18
@@ -444,10 +444,14 @@
                  write a chunk of the body */
               if(conn->protocol&PROT_HTTP) {
                 /* HTTP-only checks */
-                if (data->resume_from && !content_range ) {
+                if (data->resume_from &&
+                    !content_range &&
+                    (data->httpreq==HTTPREQ_GET)) {
                   /* we wanted to resume a download, although the server
-                     doesn't seem to support this */
-                  failf (data, "HTTP server doesn't seem to support byte ranges. Cannot resume.");
+                     doesn't seem to support this and we did this with a GET
+                     (if it wasn't a GET we did a POST or PUT resume) */
+                  failf (data, "HTTP server doesn't seem to support "
+                         "byte ranges. Cannot resume.");
                   return CURLE_HTTP_RANGE_ERROR;
                 }
                 else if (data->newurl) {
Index: url.c
===================================================================
RCS file: /cvsroot/curl/lib/url.c,v
retrieving revision 1.75
diff -u -r1.75 url.c
--- url.c	2001/01/25 12:23:57	1.75
+++ url.c	2001/01/26 15:33:19
@@ -301,6 +301,8 @@
 
     data->current_speed = -1; /* init to negative == impossible */
 
+    data->httpreq = HTTPREQ_GET; /* Default HTTP request */
+
     *curl = data;
     return CURLE_OK;
   }
@@ -340,6 +342,7 @@
     break;
   case CURLOPT_POST:
     data->bits.http_post = va_arg(param, long)?TRUE:FALSE;
+    data->httpreq = HTTPREQ_POST;
     break;
   case CURLOPT_FILETIME:
     data->bits.get_filetime = va_arg(param, long)?TRUE:FALSE;
@@ -361,19 +364,17 @@
     break;
   case CURLOPT_PUT:
     data->bits.http_put = va_arg(param, long)?TRUE:FALSE;
+    data->httpreq = HTTPREQ_PUT;
     break;
   case CURLOPT_MUTE:
     data->bits.mute = va_arg(param, long)?TRUE:FALSE;
     break;
-
   case CURLOPT_TIMECONDITION:
     data->timecondition = va_arg(param, long);
     break;
-
   case CURLOPT_TIMEVALUE:
     data->timevalue = va_arg(param, long);
     break;
-
   case CURLOPT_SSLVERSION:
     data->ssl.version = va_arg(param, long);
     break;
@@ -405,10 +406,12 @@
     break;
   case CURLOPT_CUSTOMREQUEST:
     data->customrequest = va_arg(param, char *);
+    data->httpreq = HTTPREQ_CUSTOM;
     break;
   case CURLOPT_HTTPPOST:
     data->httppost = va_arg(param, struct HttpPost *);
     data->bits.http_formpost = data->httppost?1:0;
+    data->httpreq = HTTPREQ_POST_FORM;
     break;
   case CURLOPT_INFILE:
     data->in = va_arg(param, FILE *);
Index: urldata.h
===================================================================
RCS file: /cvsroot/curl/lib/urldata.h,v
retrieving revision 1.38
diff -u -r1.38 urldata.h
--- urldata.h	2001/01/24 14:03:48	1.38
+++ urldata.h	2001/01/26 15:33:20
@@ -278,9 +278,25 @@
   char *file;    /* decoded file */
 };
 
+typedef enum {
+  HTTPREQ_NONE, /* first in list */
+  HTTPREQ_GET,
+  HTTPREQ_POST,
+  HTTPREQ_POST_FORM, /* we make a difference internally */
+  HTTPREQ_PUT,
+  HTTPREQ_CUSTOM,
+  HTTPREQ_LAST /* last in list */
+} Curl_HttpReq;
+
 /* This struct is for boolean settings that define how to behave during
    this session. */
 struct Configbits {
+  /* these four request types mirror the httpreq field */
+  bool http_formpost;
+  bool http_post;
+  bool http_put;
+  bool http_get;
+
   bool get_filetime;
   bool tunnel_thru_httpproxy;
   bool ftp_append;
@@ -290,10 +306,7 @@
   bool hide_progress;
   bool http_fail_on_error;
   bool http_follow_location;
-  bool http_formpost;
   bool http_include_header;
-  bool http_post;
-  bool http_put;
   bool http_set_referer;
   bool http_auto_referer; /* set "correct" referer when following location: */
   bool httpproxy;
@@ -308,7 +321,6 @@
   bool verbose;
   bool this_is_a_follow; /* this is a followed Location: request */
   bool krb4; /* kerberos4 connection requested */
-
   bool proxystringalloc; /* the http proxy string is malloc()'ed */
   bool rangestringalloc; /* the range string is malloc()'ed */
   bool urlstringalloc;   /* the URL string is malloc()'ed */
@@ -480,6 +492,8 @@
 
   TimeCond timecondition; /* kind of comparison */
   time_t timevalue;       /* what time to compare with */
+
+  Curl_HttpReq httpreq; /* what kind of HTTP request (if any) is this */
 
   char *customrequest; /* http/ftp request to use */
 
