1// +build go1.7 go1.8 2 3/* 4 * MinIO Go Library for Amazon S3 Compatible Cloud Storage 5 * Copyright 2017-2018 MinIO, Inc. 6 * 7 * Licensed under the Apache License, Version 2.0 (the "License"); 8 * you may not use this file except in compliance with the License. 9 * You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, software 14 * distributed under the License is distributed on an "AS IS" BASIS, 15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 * See the License for the specific language governing permissions and 17 * limitations under the License. 18 */ 19 20package minio 21 22import ( 23 "crypto/tls" 24 "net" 25 "net/http" 26 "time" 27) 28 29// DefaultTransport - this default transport is similar to 30// http.DefaultTransport but with additional param DisableCompression 31// is set to true to avoid decompressing content with 'gzip' encoding. 32var DefaultTransport = func(secure bool) (http.RoundTripper, error) { 33 tr := &http.Transport{ 34 Proxy: http.ProxyFromEnvironment, 35 DialContext: (&net.Dialer{ 36 Timeout: 30 * time.Second, 37 KeepAlive: 30 * time.Second, 38 }).DialContext, 39 MaxIdleConns: 1024, 40 MaxIdleConnsPerHost: 1024, 41 IdleConnTimeout: 90 * time.Second, 42 TLSHandshakeTimeout: 10 * time.Second, 43 ExpectContinueTimeout: 1 * time.Second, 44 // Set this value so that the underlying transport round-tripper 45 // doesn't try to auto decode the body of objects with 46 // content-encoding set to `gzip`. 47 // 48 // Refer: 49 // https://golang.org/src/net/http/transport.go?h=roundTrip#L1843 50 DisableCompression: true, 51 } 52 53 if secure { 54 tr.TLSClientConfig = &tls.Config{ 55 // Can't use SSLv3 because of POODLE and BEAST 56 // Can't use TLSv1.0 because of POODLE and BEAST using CBC cipher 57 // Can't use TLSv1.1 because of RC4 cipher usage 58 MinVersion: tls.VersionTLS12, 59 } 60 } 61 return tr, nil 62} 63