Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@ func main() {
zipServer := zip_streamer.NewServer()
zipServer.Compression = (os.Getenv("ZS_COMPRESSION") == "DEFLATE")
zipServer.ListfileUrlPrefix = os.Getenv("ZS_LISTFILE_URL_PREFIX")
zipServer.ListfileBasicAuth = os.Getenv("ZS_LISTFILE_BASIC_AUTH")

if zipServer.ListfileBasicAuth == "" {
log.Fatalf("ZS_LISTFILE_BASIC_AUTH must be set")
}

port := os.Getenv("PORT")
if port == "" {
Expand Down
6 changes: 2 additions & 4 deletions zip_streamer/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ type Server struct {
linkCache LinkCache
Compression bool
ListfileUrlPrefix string
ListfileBasicAuth string
}

func NewServer() *Server {
Expand Down Expand Up @@ -116,7 +115,7 @@ func (s *Server) HandleGetDownload(w http.ResponseWriter, req *http.Request) {
return
}

zipDescriptor, err := retrieveZipDescriptorFromUrl(listfileUrl, s.ListfileBasicAuth)
zipDescriptor, err := retrieveZipDescriptorFromUrl(listfileUrl)
if err != nil {
w.WriteHeader(http.StatusNotFound)
w.Write([]byte(`{"status":"error","error":"file not found"}`))
Expand All @@ -126,12 +125,11 @@ func (s *Server) HandleGetDownload(w http.ResponseWriter, req *http.Request) {
s.streamEntries(zipDescriptor, w, req)
}

func retrieveZipDescriptorFromUrl(listfileUrl string, listfileBasicAuth string) (*ZipDescriptor, error) {
func retrieveZipDescriptorFromUrl(listfileUrl string) (*ZipDescriptor, error) {
req, err := http.NewRequest("GET", listfileUrl, nil)
if err != nil {
return nil, err
}
req.SetBasicAuth("", listfileBasicAuth)
req.Header.Set("User-Agent", fmt.Sprintf("isic-zipstreamer/%s", getVcsRevision()))
listfileResp, err := http.DefaultClient.Do(req)
if err != nil {
Expand Down
Loading