1// +build !go1.13
2
3// Copyright (c) 2015-2021 Jeevanandam M (jeeva@myjeeva.com), All rights reserved.
4// resty source code and usage is governed by a MIT style
5// license that can be found in the LICENSE file.
6
7package resty
8
9import (
10	"net"
11	"net/http"
12	"runtime"
13	"time"
14)
15
16func createTransport(localAddr net.Addr) *http.Transport {
17	dialer := &net.Dialer{
18		Timeout:   30 * time.Second,
19		KeepAlive: 30 * time.Second,
20		DualStack: true,
21	}
22	if localAddr != nil {
23		dialer.LocalAddr = localAddr
24	}
25	return &http.Transport{
26		Proxy:                 http.ProxyFromEnvironment,
27		DialContext:           dialer.DialContext,
28		MaxIdleConns:          100,
29		IdleConnTimeout:       90 * time.Second,
30		TLSHandshakeTimeout:   10 * time.Second,
31		ExpectContinueTimeout: 1 * time.Second,
32		MaxIdleConnsPerHost:   runtime.GOMAXPROCS(0) + 1,
33	}
34}
35