Skip to content

Commit 755b77f

Browse files
http2 throws custom error Content-Length shorter handle it
We should internally handle when http2 input stream has smaller content than its content-length header Upstream issue reported golang/go#30648 This a change which we need to handle internally until Go fixes it correctly, till now our code doesn't expect a custom error to be returned.
1 parent f97a33a commit 755b77f

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

cmd/fs-v1-multipart.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"context"
2121
"encoding/json"
2222
"fmt"
23+
"io"
2324
"io/ioutil"
2425
"os"
2526
pathutil "path"
@@ -304,6 +305,10 @@ func (fs *FSObjects) PutObjectPart(ctx context.Context, bucket, object, uploadID
304305
tmpPartPath := pathJoin(fs.fsPath, minioMetaTmpBucket, fs.fsUUID, uploadID+"."+mustGetUUID()+"."+strconv.Itoa(partID))
305306
bytesWritten, err := fsCreateFile(ctx, tmpPartPath, data, buf, data.Size())
306307
if err != nil {
308+
if bytesWritten > 0 && bytesWritten < data.Size() {
309+
err = io.ErrUnexpectedEOF
310+
}
311+
307312
fsRemoveFile(ctx, tmpPartPath)
308313
return pi, toObjectErr(err, minioMetaTmpBucket, tmpPartPath)
309314
}

cmd/fs-v1.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -905,6 +905,10 @@ func (fs *FSObjects) putObject(ctx context.Context, bucket string, object string
905905
fsTmpObjPath := pathJoin(fs.fsPath, minioMetaTmpBucket, fs.fsUUID, tempObj)
906906
bytesWritten, err := fsCreateFile(ctx, fsTmpObjPath, data, buf, data.Size())
907907
if err != nil {
908+
if bytesWritten > 0 && bytesWritten < data.Size() {
909+
err = io.ErrUnexpectedEOF
910+
}
911+
908912
fsRemoveFile(ctx, fsTmpObjPath)
909913
return ObjectInfo{}, toObjectErr(err, bucket, object)
910914
}

cmd/posix.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1091,16 +1091,13 @@ func (s *posix) CreateFile(volume, path string, fileSize int64, r io.Reader) (er
10911091
defer s.pool.Put(bufp)
10921092

10931093
n, err := io.CopyBuffer(w, r, *bufp)
1094-
if err != nil {
1095-
return err
1096-
}
10971094
if n < fileSize {
10981095
return errLessData
10991096
}
11001097
if n > fileSize {
11011098
return errMoreData
11021099
}
1103-
return nil
1100+
return err
11041101
}
11051102

11061103
func (s *posix) WriteAll(volume, path string, buf []byte) (err error) {

0 commit comments

Comments
 (0)