Commit Diff


commit - 2d5ea673b339fc394958d5cff7ed0831e314597f
commit + d7988696a5b1d45dfb72b7c44fd7647389b3432b
blob - a5f2e1b28bbc8c0f51f1f3e9385f4f165dbd0b1b
blob + f59556fe906b0a5f6b8f565d12b387c701f2f4c7
--- libexec/got-fetch-http/got-fetch-http.c
+++ libexec/got-fetch-http/got-fetch-http.c
@@ -466,13 +466,11 @@ upload_request(int https, const char *host, const char
 			goto err;
 		}
 
-		/* no idea why 0000 is not enough. */
 		if (t == 0) {
-			const char *x = "00000009done\n";
-			if (http_chunk(&bio, x, strlen(x)) ||
-			    http_chunk(&bio, NULL, 0))
+			const char *flushpkt = "0000";
+			if (http_chunk(&bio, flushpkt, strlen(flushpkt)))
 				goto err;
-			break;
+			continue; /* got-fetch-pack will send "done" */
 		}
 
 		if (t < 6) {
@@ -486,6 +484,16 @@ upload_request(int https, const char *host, const char
 
 		if (http_chunk(&bio, buf, t))
 			goto err;
+
+		/*
+		 * Once got-fetch-pack is done the server will
+		 * send pack file data.
+		 */
+		if (t == 9 && strncmp(buf + 4, "done\n", 5) == 0) {
+			if (http_chunk(&bio, NULL, 0))
+				goto err;
+			break;
+		}
 	}
 
 	if (http_parse_reply(&bio, &chunked, UPLOAD_PACK_RES) == -1)