ensure http bodies closed, matrix client some kinda closed

This commit is contained in:
bel
2022-03-16 16:42:25 -06:00
parent 55bd95cc9a
commit bd71b4ecbc
3 changed files with 18 additions and 1 deletions

View File

@@ -87,7 +87,7 @@ func (fe FastExact) _login(username, password string, db storage.DB) error {
return err
}
b, _ := ioutil.ReadAll(resp.Body)
resp.Body.Close()
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
return fmt.Errorf("bad status logging into fast exact: %d: %s", resp.StatusCode, b)
@@ -152,6 +152,7 @@ func (fe FastExact) searchOneZip(zip string) ([]Job, error) {
if err != nil {
return nil, err
}
defer resp.Body.Close()
return fe.parse(resp)
}
@@ -165,6 +166,7 @@ func (fe FastExact) searchOneState(state config.State) ([]Job, error) {
if err != nil {
return nil, err
}
defer resp.Body.Close()
return fe.parse(resp)
}

View File

@@ -374,6 +374,9 @@ func (ntg NTGVision) _searchStates(states []config.State) (io.ReadCloser, error)
if err != nil {
return nil, err
}
defer resp.Body.Close()
b, _ := ioutil.ReadAll(resp.Body)
resp.Body = io.NopCloser(bytes.NewReader(b))
if resp.StatusCode != http.StatusOK {
b, _ := ioutil.ReadAll(resp.Body)
resp.Body.Close()