s3: Treat missing Content-Length as 0 for some ceph installations

s3-about
Nick Craig-Wood 2014-05-16 16:27:53 +01:00
parent 083bb154ba
commit def9adac4e
1 changed files with 9 additions and 4 deletions

View File

@ -429,10 +429,15 @@ func (o *FsObjectS3) readMetaData() (err error) {
fs.Debug(o, "Failed to read info: %s", err)
return err
}
size, err := strconv.ParseInt(headers["Content-Length"], 10, 64)
if err != nil {
fs.Debug(o, "Failed to read size from: %q", headers)
return err
var size int64
// Ignore missing Content-Length assuming it is 0
// Some versions of ceph do this due their apache proxies
if contentLength, ok := headers["Content-Length"]; ok {
size, err = strconv.ParseInt(contentLength, 10, 64)
if err != nil {
fs.Debug(o, "Failed to read size from: %q", headers)
return err
}
}
o.etag = headers["Etag"]
o.bytes = size