Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-10-20 15:13:26 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-10-20 15:13:26 +0300
commit3ce7340b2ae954b6b449bfba5720fa356b803c51 (patch)
treeab1cc089c519d0f94993142071556aa6027f0589 /workhorse/internal/upstream
parentc2afac6a378d1aaaa7448892d042cdb59ee2c290 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'workhorse/internal/upstream')
-rw-r--r--workhorse/internal/upstream/roundtripper/roundtripper.go12
-rw-r--r--workhorse/internal/upstream/roundtripper/transport.go27
2 files changed, 8 insertions, 31 deletions
diff --git a/workhorse/internal/upstream/roundtripper/roundtripper.go b/workhorse/internal/upstream/roundtripper/roundtripper.go
index fdbca5c0120..fcba50d7975 100644
--- a/workhorse/internal/upstream/roundtripper/roundtripper.go
+++ b/workhorse/internal/upstream/roundtripper/roundtripper.go
@@ -32,19 +32,23 @@ func NewBackendRoundTripper(backend *url.URL, socket string, proxyHeadersTimeout
}
func newBackendRoundTripper(backend *url.URL, socket string, proxyHeadersTimeout time.Duration, developmentMode bool, tlsConf *tls.Config) http.RoundTripper {
- // Copied from the definition of http.DefaultTransport. We can't literally copy http.DefaultTransport because of its hidden internal state.
- transport, dialer := newBackendTransport()
+ transport := http.DefaultTransport.(*http.Transport).Clone()
transport.ResponseHeaderTimeout = proxyHeadersTimeout
transport.TLSClientConfig = tlsConf
+ // Puma does not support http/2, there's no point in reconnecting
+ transport.ForceAttemptHTTP2 = false
+
+ dial := transport.DialContext
+
if backend != nil && socket == "" {
address := mustParseAddress(backend.Host, backend.Scheme)
transport.DialContext = func(ctx context.Context, network, addr string) (net.Conn, error) {
- return dialer.DialContext(ctx, "tcp", address)
+ return dial(ctx, "tcp", address)
}
} else if socket != "" {
transport.DialContext = func(ctx context.Context, network, addr string) (net.Conn, error) {
- return dialer.DialContext(ctx, "unix", socket)
+ return dial(ctx, "unix", socket)
}
} else {
panic("backend is nil and socket is empty")
diff --git a/workhorse/internal/upstream/roundtripper/transport.go b/workhorse/internal/upstream/roundtripper/transport.go
deleted file mode 100644
index 84d9623b129..00000000000
--- a/workhorse/internal/upstream/roundtripper/transport.go
+++ /dev/null
@@ -1,27 +0,0 @@
-package roundtripper
-
-import (
- "net"
- "net/http"
- "time"
-)
-
-// newBackendTransport setups the default HTTP transport which Workhorse uses
-// to communicate with the upstream
-func newBackendTransport() (*http.Transport, *net.Dialer) {
- dialler := &net.Dialer{
- Timeout: 30 * time.Second,
- KeepAlive: 30 * time.Second,
- }
-
- transport := &http.Transport{
- Proxy: http.ProxyFromEnvironment,
- DialContext: dialler.DialContext,
- MaxIdleConns: 100,
- IdleConnTimeout: 90 * time.Second,
- TLSHandshakeTimeout: 10 * time.Second,
- ExpectContinueTimeout: 1 * time.Second,
- }
-
- return transport, dialler
-}