Permalink
Browse files

Only one proxy

  • Loading branch information...
rosylilly committed Oct 31, 2015
1 parent 588d0da commit f910cfc4373efa0560d909b8ffb28d7e14c99ec0
Showing with 7 additions and 3 deletions.
  1. +7 −3 5f/webapp/golang/proxy.go
View
@@ -129,21 +129,25 @@ func copyHeaders(dst, src *http.Header) {
}
var clients = map[string]*http.Client{}
+var client *http.Client
func getClinet(token string) *http.Client {
mutex.Lock()
defer mutex.Unlock()
+ if client != nil {
+ return client
+ }
+
cli, ok := clients[token]
if ok {
return cli
}
tr := &httpclient.Transport{
- MaxIdleConnsPerHost: 1,
+ MaxIdleConnsPerHost: 10,
ConnectTimeout: 2 * time.Second,
DisableKeepAlives: false,
- DisableCompression: true,
TLSClientConfig: &tls.Config{
InsecureSkipVerify: true,
},
@@ -168,7 +172,7 @@ func getClinet(token string) *http.Client {
}
}()
- client := &http.Client{Transport: tr}
+ client = &http.Client{Transport: tr}
client.CheckRedirect = func(req *http.Request, via []*http.Request) error {
if len(via) >= 8 {
return errors.New("Too many redirects")

0 comments on commit f910cfc

Please sign in to comment.