MCPcopy
hub / github.com/tuna/tunasync / CreateHTTPClient

Function CreateHTTPClient

internal/util.go:60–80  ·  view source on GitHub ↗

CreateHTTPClient returns a http.Client

(CAFile string)

Source from the content-addressed store, hash-verified

58
59// CreateHTTPClient returns a http.Client
60func CreateHTTPClient(CAFile string) (*http.Client, error) {
61 var tlsConfig *tls.Config
62 var err error
63
64 if CAFile != "" {
65 tlsConfig, err = GetTLSConfig(CAFile)
66 if err != nil {
67 return nil, err
68 }
69 }
70
71 tr := &http.Transport{
72 MaxIdleConnsPerHost: 20,
73 TLSClientConfig: tlsConfig,
74 }
75
76 return &http.Client{
77 Transport: tr,
78 Timeout: 5 * time.Second,
79 }, nil
80}
81
82// PostJSON posts json object to url
83func PostJSON(url string, obj interface{}, client *http.Client) (*http.Response, error) {

Callers 5

TestWorkerFunction · 0.85
NewTUNASyncWorkerFunction · 0.85
PostJSONFunction · 0.85
GetJSONFunction · 0.85
GetTUNASyncManagerFunction · 0.85

Calls 1

GetTLSConfigFunction · 0.85

Tested by 1

TestWorkerFunction · 0.68