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

Add DisableCompression in http.Transport to override auto-decompress. #752

Merged
merged 1 commit into from
Jul 14, 2017

Conversation

harshavardhana
Copy link
Member

@harshavardhana harshavardhana force-pushed the accept-encoding branch 4 times, most recently from a19bdd8 to eabacd4 Compare July 11, 2017 18:38
@deekoder deekoder requested review from krisis and vadmeste July 11, 2017 23:46
req.Header.Set("Content-Encoding", strings.Join([]string{contentEncoding, streamingEncoding}, ","))
} else {
req.Header.Set("Content-Encoding", streamingEncoding)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

instead you can just do:
req.Header.Add("Content-Encoding", streamingEncoding)

Copy link
Member Author

Choose a reason for hiding this comment

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

Oops yes forgot :P @krishnasrinivas

api.go Outdated
// uncompress the gzip stream if we were the layer that
// requested it. ""
//
req.Header.Set("Accept-Encoding", "gzip")
Copy link
Member

@vadmeste vadmeste Jul 12, 2017

Choose a reason for hiding this comment

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

Aren't we here literally saying: hey server, we can accept content in compressed format to gain bandwidth, now if the server supports that feature, will the client really be able to decompress content before delivering it to our users ?

Besides.. I am noticing this weird behavior, an empty Content-Encoding: header returned by AWS S3, but it seems it has nothing to do with this PR.

GET /presignedgetobject.go HTTP/1.1
Host: vadmeste.s3.amazonaws.com
User-Agent: Minio (linux; amd64) minio-go/3.0.0
Accept-Encoding: gzip
Authorization: AWS4-HMAC-SHA256 Credential=**REDACTED**/20170712/us-east-1/s3/aws4_request, SignedHeaders=accept-encoding;host;if-match;x-amz-content-sha256;x-amz-date, Signatu
re=**REDACTED**
If-Match: "6795a04d7e56a596c4cacafc0c148ae8"
X-Amz-Content-Sha256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
X-Amz-Date: 20170712T151340Z

HTTP/1.1 200 OK
Content-Length: 1736
Accept-Ranges: bytes
Content-Encoding:
Content-Type: application/octet-stream
Date: Wed, 12 Jul 2017 15:13:41 GMT
Etag: "6795a04d7e56a596c4cacafc0c148ae8"
Last-Modified: Wed, 12 Jul 2017 15:12:55 GMT
Server: AmazonS3
X-Amz-Id-2: jt7yeuBacaGCBGdU1cJ1BVGZTAKZdWy5u3u7expyF61LyTBiARPqC/sPpSOQbHbC6+3HdTAoafw=
X-Amz-Request-Id: 9071463091587F0D

@harshavardhana
Copy link
Member Author

harshavardhana commented Jul 12, 2017

Aren't we here literally saying: hey server, we can accept content in compressed format to gain bandwidth, now if the server supports that feature, will the client really be able to decompress content before delivering it to our users ?

Yes that is correct indication but we are doing that to avoid auto-decompress for copying and streaming. Such that out GetObject() gets a compressed stream and the caller can decide on decompressing it or un-compressing it. minio-go client will not do any data manipulation.

@harshavardhana
Copy link
Member Author

harshavardhana commented Jul 12, 2017

Yes that is correct indication but we are doing that to avoid auto-decompress for copying and streaming. Such that out GetObject() gets a compressed stream and the caller can decide on decompressing it or un-compressing it. minio-go client will not do any data manipulation.

Found a way to avoid setting any additional headers instead just use DisableCompression: true in the http.DefaultTranport which is more easier way to understand solves this problem.

@harshavardhana harshavardhana changed the title Add accept-encoding to override auto-decompress. Add DisableCompression in http.Transport to override auto-decompress. Jul 12, 2017
api.go Outdated
//
// Refer:
// https://golang.org/src/net/http/transport.go?h=roundTrip#L1843
DisableCompression: true,
Copy link
Member

Choose a reason for hiding this comment

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

We also need to do this in mc since mc sets its custom transport (primarily to satisfy --insecure flag). But I am OK with this.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes we need to. @vadmeste

vadmeste
vadmeste previously approved these changes Jul 12, 2017
Copy link
Member

@vadmeste vadmeste left a comment

Choose a reason for hiding this comment

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

LGTM

@harshavardhana harshavardhana force-pushed the accept-encoding branch 3 times, most recently from 8ec0c4f to 050e76c Compare July 13, 2017 07:44
@harshavardhana
Copy link
Member Author

ping @vadmeste waiting on your review.

Copy link
Member

@vadmeste vadmeste left a comment

Choose a reason for hiding this comment

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

LGTM

@deekoder deekoder merged commit 4415743 into minio:master Jul 14, 2017
@harshavardhana harshavardhana deleted the accept-encoding branch July 14, 2017 21:41
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.

5 participants