diff --git a/lib/transfer.c b/lib/transfer.c
index 42d38b5..96c2701 100644
--- a/lib/transfer.c
+++ b/lib/transfer.c
@@ -223,6 +223,11 @@ CURLcode Curl_fillreadbuffer(struct connectdata *conn, int bytes, int *nreadp)
 
     nread+=(int)strlen(endofline_native); /* for the added end of line */
   }
+  else if ( nread == 0 )
+  {
+    /* fread_func signaled transfer is finished -> mark as done */
+    data->req.upload_done = TRUE;
+  }
 #ifdef CURL_DOES_CONVERSIONS
   else if((data->set.prefer_ascii) && (!sending_http_headers)) {
     CURLcode result;
@@ -1074,6 +1079,14 @@ CURLcode Curl_readwrite(struct connectdata *conn,
     result = readwrite_upload(data, conn, k, &didwhat);
     if(result)
       return result;
+
+    /* If we are still sending call readwrite_upload() again to check if we got EOF */
+    if ( k->keepon & KEEP_SEND )
+    {
+      result = readwrite_upload(data, conn, k, &didwhat);
+      if(result)
+        return result;
+    }
   }
 
   k->now = Curl_tvnow();

