Commit 9af1de5bc5b57a68bd659e9f76540c3f569772e8

Edward Thomson 2019-03-24T20:49:57

http: stop on server EOF We stop the read loop when we have read all the data. We should also consider the server's feelings. If the server hangs up on us, we need to stop our read loop. Otherwise, we'll try to read from the server - and fail - ad infinitum.

diff --git a/src/transports/http.c b/src/transports/http.c
index 8e0af1b..d2ae559 100644
--- a/src/transports/http.c
+++ b/src/transports/http.c
@@ -934,8 +934,13 @@ replay:
 	while (!bytes_read && !t->parse_finished) {
 		t->parse_buffer.offset = 0;
 
-		if ((error = gitno_recv(&t->parse_buffer)) < 0)
+		if ((error = gitno_recv(&t->parse_buffer)) < 0) {
 			goto done;
+		} else if (error == 0) {
+			git_error_set(GIT_ERROR_NET, "unexpected disconnection from server");
+			error = -1;
+			goto done;
+		}
 
 		/*
 		 * This call to http_parser_execute will invoke the on_*
@@ -1178,8 +1183,13 @@ replay:
 
 		data_offset = t->parse_buffer.offset;
 
-		if ((error = gitno_recv(&t->parse_buffer)) < 0)
+		if ((error = gitno_recv(&t->parse_buffer)) < 0) {
 			goto done;
+		} else if (error == 0) {
+			git_error_set(GIT_ERROR_NET, "unexpected disconnection from server");
+			error = -1;
+			goto done;
+		}
 
 		/*
 		 * This call to http_parser_execute will result in invocations