Skip to content
Permalink
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.
  • Loading branch information...
harshavardhana committed Mar 6, 2019
1 parent f97a33a commit 755b77f28d41f6112d5571f9e1e4c40c53e8d0a3
Showing with 10 additions and 4 deletions.
  1. +5 −0 cmd/fs-v1-multipart.go
  2. +4 −0 cmd/fs-v1.go
  3. +1 −4 cmd/posix.go
@@ -20,6 +20,7 @@ import (
"context"
"encoding/json"
"fmt"
"io"
"io/ioutil"
"os"
pathutil "path"
@@ -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))
bytesWritten, err := fsCreateFile(ctx, tmpPartPath, data, buf, data.Size())
if err != nil {
if bytesWritten > 0 && bytesWritten < data.Size() {
err = io.ErrUnexpectedEOF
}

fsRemoveFile(ctx, tmpPartPath)
return pi, toObjectErr(err, minioMetaTmpBucket, tmpPartPath)
}
@@ -905,6 +905,10 @@ func (fs *FSObjects) putObject(ctx context.Context, bucket string, object string
fsTmpObjPath := pathJoin(fs.fsPath, minioMetaTmpBucket, fs.fsUUID, tempObj)
bytesWritten, err := fsCreateFile(ctx, fsTmpObjPath, data, buf, data.Size())
if err != nil {
if bytesWritten > 0 && bytesWritten < data.Size() {
err = io.ErrUnexpectedEOF
}

fsRemoveFile(ctx, fsTmpObjPath)
return ObjectInfo{}, toObjectErr(err, bucket, object)
}
@@ -1091,16 +1091,13 @@ func (s *posix) CreateFile(volume, path string, fileSize int64, r io.Reader) (er
defer s.pool.Put(bufp)

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

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

0 comments on commit 755b77f

Please sign in to comment.
You can’t perform that action at this time.