Files
faas-cli/proxy/proxy.go
Alex Ellis b05b52960a Spaces between header and code
Signed-off-by: Alex Ellis <alexellis2@gmail.com>
2017-10-23 17:07:08 +01:00

34 lines
845 B
Go

// Copyright (c) Alex Ellis 2017. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
package proxy
import (
"net"
"net/http"
"time"
)
// MakeHTTPClient makes a HTTP client with good defaults for timeouts.
func MakeHTTPClient(timeout *time.Duration) http.Client {
if timeout != nil {
return http.Client{
Timeout: 3 * time.Second,
Transport: &http.Transport{
Proxy: http.ProxyFromEnvironment,
DialContext: (&net.Dialer{
Timeout: 3 * time.Second,
// KeepAlive: 0,
}).DialContext,
// MaxIdleConns: 1,
// DisableKeepAlives: true,
IdleConnTimeout: 120 * time.Millisecond,
ExpectContinueTimeout: 1500 * time.Millisecond,
},
}
}
// This should be used for faas-cli invoke etc.
return http.Client{}
}