Skip to content

Commit

Permalink
http2 throws custom error Content-Length shorter handle it
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
harshavardhana committed Mar 7, 2019
1 parent f97a33a commit 755b77f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
5 changes: 5 additions & 0 deletions cmd/fs-v1-multipart.go
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"context" "context"
"encoding/json" "encoding/json"
"fmt" "fmt"
"io"
"io/ioutil" "io/ioutil"
"os" "os"
pathutil "path" pathutil "path"
Expand Down Expand Up @@ -304,6 +305,10 @@ func (fs *FSObjects) PutObjectPart(ctx context.Context, bucket, object, uploadID
tmpPartPath := pathJoin(fs.fsPath, minioMetaTmpBucket, fs.fsUUID, uploadID+"."+mustGetUUID()+"."+strconv.Itoa(partID)) tmpPartPath := pathJoin(fs.fsPath, minioMetaTmpBucket, fs.fsUUID, uploadID+"."+mustGetUUID()+"."+strconv.Itoa(partID))
bytesWritten, err := fsCreateFile(ctx, tmpPartPath, data, buf, data.Size()) bytesWritten, err := fsCreateFile(ctx, tmpPartPath, data, buf, data.Size())
if err != nil { if err != nil {
if bytesWritten > 0 && bytesWritten < data.Size() {
err = io.ErrUnexpectedEOF
}

fsRemoveFile(ctx, tmpPartPath) fsRemoveFile(ctx, tmpPartPath)
return pi, toObjectErr(err, minioMetaTmpBucket, tmpPartPath) return pi, toObjectErr(err, minioMetaTmpBucket, tmpPartPath)
} }
Expand Down
4 changes: 4 additions & 0 deletions cmd/fs-v1.go
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -905,6 +905,10 @@ func (fs *FSObjects) putObject(ctx context.Context, bucket string, object string
fsTmpObjPath := pathJoin(fs.fsPath, minioMetaTmpBucket, fs.fsUUID, tempObj) fsTmpObjPath := pathJoin(fs.fsPath, minioMetaTmpBucket, fs.fsUUID, tempObj)
bytesWritten, err := fsCreateFile(ctx, fsTmpObjPath, data, buf, data.Size()) bytesWritten, err := fsCreateFile(ctx, fsTmpObjPath, data, buf, data.Size())
if err != nil { if err != nil {
if bytesWritten > 0 && bytesWritten < data.Size() {
err = io.ErrUnexpectedEOF
}

fsRemoveFile(ctx, fsTmpObjPath) fsRemoveFile(ctx, fsTmpObjPath)
return ObjectInfo{}, toObjectErr(err, bucket, object) return ObjectInfo{}, toObjectErr(err, bucket, object)
} }
Expand Down
5 changes: 1 addition & 4 deletions cmd/posix.go
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -1091,16 +1091,13 @@ func (s *posix) CreateFile(volume, path string, fileSize int64, r io.Reader) (er
defer s.pool.Put(bufp) defer s.pool.Put(bufp)


n, err := io.CopyBuffer(w, r, *bufp) n, err := io.CopyBuffer(w, r, *bufp)
if err != nil {
return err
}
if n < fileSize { if n < fileSize {
return errLessData return errLessData
} }
if n > fileSize { if n > fileSize {
return errMoreData return errMoreData
} }
return nil return err
} }


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

0 comments on commit 755b77f

Please sign in to comment.