Skip to content

Commit

Permalink
Merge pull request #402 from oysteing/bugfix/388
Browse files Browse the repository at this point in the history
Support Chunked Transfer-Encoding. Refs #388
  • Loading branch information
loafoe authored Jul 29, 2022
2 parents 9eff484 + 2b57c00 commit 6c325d2
Showing 1 changed file with 26 additions and 5 deletions.
31 changes: 26 additions & 5 deletions cloudfoundry/managers/bits/bitsmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -321,11 +321,32 @@ func (m BitsManager) RetrieveZip(path string) (ZipFile, error) {
baseName = params["filename"]
}
}
return ZipFile{
r: resp.Body,
baseName: baseName,
filesize: fileSize,
}, nil
if fileSize > 0 {
return ZipFile{
r: resp.Body,
baseName: baseName,
filesize: fileSize,
}, nil
} else {
tempFile, err := ioutil.TempFile("", "")
if err != nil {
return ZipFile{}, err
}
defer os.Remove(tempFile.Name())
fileSize, err := io.Copy(tempFile, resp.Body)
if err != nil {
return ZipFile{}, err
}
_, err = tempFile.Seek(0, 0)
if err != nil {
return ZipFile{}, err
}
return ZipFile{
r: tempFile,
baseName: baseName,
filesize: fileSize,
}, nil
}
}
f, err := os.Open(path)
if err != nil {
Expand Down

0 comments on commit 6c325d2

Please sign in to comment.