transport.go 1.6 KB

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