internal/gitserver: Reuse code to read response body
Created by: indradhanush
Change inspired after working on #39358.
This commit has two positive effects:
- It unifies all code to read the response body in case of non 200 HTTP response in the client.go file and makes it consistent
- It stops ignoring the error from io.ReadAll
Test plan
Existing tests should pass.