transport_1_6.go 554 B

123456789101112131415161718192021222324
  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. // new Transport
  10. transport := &http.Transport{
  11. Dial: func(netw, addr string) (net.Conn, error) {
  12. conn, err := net.DialTimeout(netw, addr, httpTimeOut.ConnectTimeout)
  13. if err != nil {
  14. return nil, err
  15. }
  16. return newTimeoutConn(conn, httpTimeOut.ReadWriteTimeout, httpTimeOut.LongTimeout), nil
  17. },
  18. ResponseHeaderTimeout: httpTimeOut.HeaderTimeout,
  19. }
  20. return transport
  21. }