Index: src/http.c
==================================================================
--- src/http.c
+++ src/http.c
@@ -190,12 +190,14 @@
   }
 
   /*
   ** Send the request to the server.
   */
-  transport_send(&hdr);
-  transport_send(&payload);
+  if (transport_send(&hdr))
+	goto write_err;
+  if (transport_send(&payload))
+	goto write_err;
   blob_reset(&hdr);
   blob_reset(&payload);
   transport_flip();
   
   /*

Index: src/http_ssl.c
==================================================================
--- src/http_ssl.c
+++ src/http_ssl.c
@@ -249,11 +249,11 @@
       int j;
       for( j = 0; j < mdLength; ++j ) {
         BIO_printf(mem, " %02x", md[j]);
       }
     }
-    BIO_write(mem, "", 1); // null-terminate mem buffer
+    BIO_write(mem, "", 1); /* null-terminate mem buffer */
     BIO_get_mem_data(mem, &desc);
     
     if( hasSavedCertificate ){
       warning = "WARNING: Certificate doesn't match the "
                 "saved certificate for this host!";
@@ -304,11 +304,11 @@
   BIO *mem;
   char *zCert, *zHost;
 
   mem = BIO_new(BIO_s_mem());
   PEM_write_bio_X509(mem, cert);
-  BIO_write(mem, "", 1); // null-terminate mem buffer
+  BIO_write(mem, "", 1); /* null-terminate mem buffer */
   BIO_get_mem_data(mem, &zCert);
   zHost = mprintf("cert:%s", g.urlName);
   db_set(zHost, zCert, 1);
   free(zHost);
   BIO_free(mem);  

Index: src/http_transport.c
==================================================================
--- src/http_transport.c
+++ src/http_transport.c
@@ -259,41 +259,48 @@
   }
 }
 
 /*
 ** Send content over the wire.
+** Returns whether sending was errant, i.e.,
+** the count of bytes written onto the wire does
+** not equal the size of the blob being sent.
 */
-void transport_send(Blob *toSend){
+int transport_send(Blob *toSend){
   char *z = blob_buffer(toSend);
   int n = blob_size(toSend);
-  transport.nSent += n;
+  size_t written = 0;
   if( g.urlIsSsh ){
-    int sent;
-    sent = fwrite(z, 1, n, sshOut);
+    written = fwrite(z, 1, n, sshOut);
     fflush(sshOut);
-    /* printf("sent %d of %d bytes\n", sent, n); fflush(stdout); */
+    /* printf("sent %d of %d bytes\n", (unsigned long) written, n); fflush(stdout); */
   }else if( g.urlIsHttps ){
     #ifdef FOSSIL_ENABLE_SSL
     int sent;
     while( n>0 ){
       sent = ssl_send(0, z, n);
       /* printf("Sent %d of %d bytes\n", sent, n); fflush(stdout); */
       if( sent<=0 ) break;
       n -= sent;
+      written += sent;
     }    
     #endif
   }else if( g.urlIsFile ){
-    fwrite(z, 1, n, transport.pFile);
+    written = fwrite(z, 1, n, transport.pFile);
+    /* printf("written %d of %d bytes\n", (unsigned long) written, n); fflush(stdout); */
   }else{
     int sent;
     while( n>0 ){
       sent = socket_send(0, z, n);
       /* printf("Sent %d of %d bytes\n", sent, n); fflush(stdout); */
       if( sent<=0 ) break;
       n -= sent;
+      written += sent;
     }
   }
+  transport.nSent += written;
+  return (blob_size(toSend) != written);
 }
 
 /*
 ** This routine is called when the outbound message is complete and
 ** it is time to being recieving a reply.

Index: src/xfer.c
==================================================================
--- src/xfer.c
+++ src/xfer.c
@@ -1713,11 +1713,11 @@
     ** we have gone at least two rounds.  Always go at least two rounds
     ** on a clone in order to be sure to retrieve the configuration
     ** information which is only sent on the second round.
     */
     if( cloneSeqno<=0 && nCycle>1 ) go = 0;   
-  };
+  }
   transport_stats(&nSent, &nRcvd, 1);
   fossil_print("Total network traffic: %lld bytes sent, %lld bytes received\n",
                nSent, nRcvd);
   transport_close();
   transport_global_shutdown();