]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - cups/getputfile.c
Load cups into easysw/current.
[thirdparty/cups.git] / cups / getputfile.c
index 4a78a42df2367309244c4f4057f9d43d1f74e803..6c534a70f0eceb8de2563df74f6e13651033d161 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: getputfile.c 5138 2006-02-21 10:49:06Z mike $"
+ * "$Id: getputfile.c 5147 2006-02-22 16:37:44Z mike $"
  *
  *   Get/put file functions for the Common UNIX Printing System (CUPS).
  *
@@ -295,6 +295,7 @@ cupsPutFd(http_t     *http,         /* I - HTTP connection to server */
     httpClearFields(http);
     httpSetField(http, HTTP_FIELD_AUTHORIZATION, http->authstring);
     httpSetField(http, HTTP_FIELD_TRANSFER_ENCODING, "chunked");
+    httpSetExpect(http, HTTP_CONTINUE);
 
     if (httpPut(http, resource))
     {
@@ -311,21 +312,31 @@ cupsPutFd(http_t     *http,               /* I - HTTP connection to server */
     }
 
    /*
-    * Copy the file...
+    * Wait up to 1 second for a 100-continue response...
     */
 
-    lseek(fd, 0, SEEK_SET);
+    if (httpWait(http, 1000))
+      status = httpUpdate(http);
+    else
+      status = HTTP_CONTINUE;
 
-    status = HTTP_CONTINUE;
+    if (status == HTTP_CONTINUE)
+    {
+     /*
+      * Copy the file...
+      */
 
-    while ((bytes = read(fd, buffer, sizeof(buffer))) > 0)
-      if (httpCheck(http))
-      {
-        if ((status = httpUpdate(http)) != HTTP_CONTINUE)
-          break;
-      }
-      else
-        httpWrite2(http, buffer, bytes);
+      lseek(fd, 0, SEEK_SET);
+
+      while ((bytes = read(fd, buffer, sizeof(buffer))) > 0)
+       if (httpCheck(http))
+       {
+          if ((status = httpUpdate(http)) != HTTP_CONTINUE)
+            break;
+       }
+       else
+          httpWrite2(http, buffer, bytes);
+    }
 
     if (status == HTTP_CONTINUE)
     {
@@ -471,5 +482,5 @@ cupsPutFile(http_t     *http,               /* I - HTTP connection to server */
 
 
 /*
- * End of "$Id: getputfile.c 5138 2006-02-21 10:49:06Z mike $".
+ * End of "$Id: getputfile.c 5147 2006-02-22 16:37:44Z mike $".
  */