internal/extsvc/github: Return httpResponseState from doRequest
Created by: indradhanush
Patch related to #25904. Pre-requisite to #31275.
In this commit, we change the internal API doRequest
to return a new
custom type httpResponseState
which contains both the
http.Response.StatusCode
and the http.Response.Header
.
doRequest
(apart from HTTP request
errors). As a result the caller has no visibility for a conditional
request.
requestGet
requestGetWithHeader
requestBody
- The
doRequest
returns an APIError object which already contains the HTTP StatusCode in case the HTTP request errored out. And with this method now also returning thehttp.Response.StatusCode
as well, this feels somewhat redundant and could possibly be cleaned up further. However, external callers rely on the APIError object at the moment, so refactoring this increases the patch size with little gains.
[0]: https://docs.github.com/en/rest/overview/resources-in-the-rest-api#conditional-requests
Test Plan
Internal API design change only. No functionality change. Tested locally that sg start
works successfully.