transport_1_7.go 760 B

12345678910111213141516171819202122232425262728
  1. // +build go1.7
  2. package oss
  3. import (
  4. "net"
  5. "net/http"
  6. )
  7. func newTransport(conn *Conn, config *Config) *http.Transport {
  8. httpTimeOut := conn.config.HTTPTimeout
  9. httpMaxConns := conn.config.HTTPMaxConns
  10. // New Transport
  11. transport := &http.Transport{
  12. Dial: func(netw, addr string) (net.Conn, error) {
  13. conn, err := net.DialTimeout(netw, addr, httpTimeOut.ConnectTimeout)
  14. if err != nil {
  15. return nil, err
  16. }
  17. return newTimeoutConn(conn, httpTimeOut.ReadWriteTimeout, httpTimeOut.LongTimeout), nil
  18. },
  19. MaxIdleConns: httpMaxConns.MaxIdleConns,
  20. MaxIdleConnsPerHost: httpMaxConns.MaxIdleConnsPerHost,
  21. IdleConnTimeout: httpTimeOut.IdleConnTimeout,
  22. ResponseHeaderTimeout: httpTimeOut.HeaderTimeout,
  23. }
  24. return transport
  25. }