Skip to content

Commit

Permalink
Zeus: check for status code in ModuleStore.Get (gomods#224)
Browse files Browse the repository at this point in the history
  • Loading branch information
marwan-at-work authored and michalpristas committed Jul 9, 2018
1 parent c02e9c0 commit da009db
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions pkg/storage/olympus/getter.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"bytes"
"fmt"
"io/ioutil"
"net/http"

"github.com/gomods/athens/pkg/config"
"github.com/gomods/athens/pkg/storage"
Expand All @@ -25,6 +26,9 @@ func (s *ModuleStore) Get(module, vsn string) (*storage.Version, error) {
return nil, err
}
defer modResp.Body.Close()
if modResp.StatusCode != http.StatusOK {
return nil, fmt.Errorf("GET %v returned unexpected status: %v", modURI, modResp.StatusCode)
}

mod, err = ioutil.ReadAll(modResp.Body)
if err != nil {
Expand All @@ -38,6 +42,9 @@ func (s *ModuleStore) Get(module, vsn string) (*storage.Version, error) {
return nil, err
}
defer zipResp.Body.Close()
if zipResp.StatusCode != http.StatusOK {
return nil, fmt.Errorf("GET %v returned unexpected status: %v", zipURI, zipResp.StatusCode)
}

zip, err = ioutil.ReadAll(zipResp.Body)
if err != nil {
Expand All @@ -51,6 +58,9 @@ func (s *ModuleStore) Get(module, vsn string) (*storage.Version, error) {
return nil, err
}
defer infoResp.Body.Close()
if infoResp.StatusCode != http.StatusOK {
return nil, fmt.Errorf("GET %v returned unexpected status: %v", infoURI, infoResp.StatusCode)
}

info, err = ioutil.ReadAll(infoResp.Body)
if err != nil {
Expand Down

0 comments on commit da009db

Please sign in to comment.