transport_1_6.go 655 B

1234567891011121314151617181920212223242526
  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. MaxIdleConnsPerHost: httpMaxConns.MaxIdleConnsPerHost,
  20. ResponseHeaderTimeout: httpTimeOut.HeaderTimeout,
  21. }
  22. return transport
  23. }