Add basic auth and fix repair issues

This commit is contained in:
Ben Sarmiento
2024-01-09 16:53:12 +01:00
parent eb3f2785ce
commit 91f6d35831
7 changed files with 73 additions and 39 deletions

View File

@@ -153,12 +153,13 @@ func (r *HTTPClient) Do(req *http.Request) (*http.Response, error) {
attempt := 0
for {
resp, err = r.client.Do(req)
if resp != nil && resp.StatusCode != http.StatusOK && resp.StatusCode != http.StatusPartialContent {
if resp != nil && (resp.StatusCode < http.StatusOK || resp.StatusCode > http.StatusPartialContent) {
body, _ := io.ReadAll(resp.Body)
if body != nil {
var errResp ErrorResponse
jsonErr := json.Unmarshal(body, &errResp)
if jsonErr == nil {
errResp.Message += fmt.Sprintf(" (status code: %d)", resp.StatusCode)
err = &errResp
}
}