From def9adac4ec8d0be312cc5ae16e31c9daa4dcfe0 Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Fri, 16 May 2014 16:27:53 +0100 Subject: [PATCH] s3: Treat missing Content-Length as 0 for some ceph installations --- s3/s3.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/s3/s3.go b/s3/s3.go index b38994767..45a543b36 100644 --- a/s3/s3.go +++ b/s3/s3.go @@ -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