Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sure to pass the contentBody to NewRequest appropriately. #614

Merged
merged 1 commit into from
Feb 17, 2017

Conversation

harshavardhana
Copy link
Member

This is needed since in go1.8 wrapping the body can cause
content-length to be not calculated properly, which would
lead to failures on the server side when uploading a zero
byte object.

// Initialize a new temporary buffer.
tmpBuffer := new(bytes.Buffer)
size, err = hashCopyN(hashAlgos, hashSums, tmpBuffer, reader, size)
if err != nil {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, hashCopyN can return io.EOF in normal conditions (not sure why), besides, there is a check of err later.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hashCopy should be io.Copy equivalent so should never return io.EOF

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fixed.

@@ -205,10 +205,13 @@ func (c Client) putObjectSingle(bucketName, objectName string, reader io.Reader,
hashAlgos["sha256"] = sha256.New()
}

if size <= minPartSize {
if size <= minPutBufferSize {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was minPartSize, it means else was never entered, it could have buggy code.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually let me revert this back its not needed with this patch.

@harshavardhana harshavardhana force-pushed the nop-closer branch 3 times, most recently from c97bc52 to d344199 Compare February 17, 2017 19:27
This is needed since in go1.8 wrapping the body can cause
content-length to be not calculated properly, which would
lead to failures on the server side when uploading a zero
byte object.
@harshavardhana harshavardhana merged commit 7a3619e into minio:master Feb 17, 2017
@harshavardhana harshavardhana deleted the nop-closer branch February 17, 2017 20:03
vadmeste added a commit to vadmeste/minio-go that referenced this pull request Mar 9, 2017
vadmeste added a commit to vadmeste/minio-go that referenced this pull request Mar 9, 2017
vadmeste added a commit to vadmeste/minio-go that referenced this pull request Mar 9, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants