commit 06dc3607479d190ff1dacaad2823903c41ff024f from: Stefan Sperling via: Thomas Adam date: Thu Apr 25 14:57:52 2024 UTC make got-fetch-http pass "done\n" through rather than faking it Without this we exit the loop early and got-fetch-pack sees unexpected end-of-file on stdout trying to write its final "done\n" message. ok op@ commit - a1aebf7f29c0d61ba32c965290bc8d8f3369b782 commit + 06dc3607479d190ff1dacaad2823903c41ff024f 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)