Skip to content

Commit 04c7bdb

Browse files
committed
httpclient: clear the read_buf on new requests
The httpclient implementation keeps a `read_buf` that holds the data in the body of the response after the headers have been written. We store that data for subsequent calls to `git_http_client_read_body`. If we want to stop reading body data and send another request, we need to clear that cached data. Clear the cached body data on new requests, just like we read any outstanding data from the socket.
1 parent aa8b2c0 commit 04c7bdb

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/transports/httpclient.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1195,7 +1195,7 @@ static void complete_response_body(git_http_client *client)
11951195
/* If we're not keeping alive, don't bother. */
11961196
if (!client->keepalive) {
11971197
client->connected = 0;
1198-
return;
1198+
goto done;
11991199
}
12001200

12011201
parser_context.client = client;
@@ -1209,6 +1209,9 @@ static void complete_response_body(git_http_client *client)
12091209
git_error_clear();
12101210
client->connected = 0;
12111211
}
1212+
1213+
done:
1214+
git_buf_clear(&client->read_buf);
12121215
}
12131216

12141217
int git_http_client_send_request(

0 commit comments

Comments
 (0)