transport_1_7.go 607 B

12345678910111213141516171819202122232425
  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. IdleConnTimeout: httpTimeOut.IdleConnTimeout,
  19. ResponseHeaderTimeout: httpTimeOut.HeaderTimeout,
  20. }
  21. return transport
  22. }