Commit db0dc783 authored by Jacob Vosmaer's avatar Jacob Vosmaer

Hide ResponseHeaderTimeout

parent 6951b3e4
......@@ -18,15 +18,14 @@ var DefaultDialer = &net.Dialer{
}
var DefaultTransport = &http.Transport{
Proxy: http.ProxyFromEnvironment, // from http.DefaultTransport
Dial: DefaultDialer.Dial, // from http.DefaultTransport
ResponseHeaderTimeout: time.Minute, // custom
TLSHandshakeTimeout: 10 * time.Second, // from http.DefaultTransport
Proxy: http.ProxyFromEnvironment, // from http.DefaultTransport
Dial: DefaultDialer.Dial, // from http.DefaultTransport
TLSHandshakeTimeout: 10 * time.Second, // from http.DefaultTransport
}
type RoundTripper struct {
Socket string
ResponseHeaderTimeout time.Duration
ProxyHeadersTimeout time.Duration
Transport *http.Transport
configureRoundTripperOnce sync.Once
}
......@@ -69,10 +68,7 @@ func (t *RoundTripper) configureRoundTripper() {
}
tr := *DefaultTransport
if t.ResponseHeaderTimeout != 0 {
tr.ResponseHeaderTimeout = t.ResponseHeaderTimeout
}
tr.ResponseHeaderTimeout = t.ProxyHeadersTimeout
if t.Socket != "" {
tr.Dial = func(_, _ string) (net.Conn, error) {
......
......@@ -21,12 +21,12 @@ import (
var DefaultBackend = helper.URLMustParse("http://localhost:8080")
type Upstream struct {
Backend *url.URL
Version string
Socket string
DocumentRoot string
DevelopmentMode bool
ResponseHeaderTimeout time.Duration
Backend *url.URL
Version string
Socket string
DocumentRoot string
DevelopmentMode bool
ProxyHeadersTimeout time.Duration
urlPrefix urlprefix.Prefix
configureURLPrefixOnce sync.Once
......@@ -56,8 +56,8 @@ func (u *Upstream) URLPrefix() urlprefix.Prefix {
func (u *Upstream) RoundTripper() *badgateway.RoundTripper {
u.configureRoundTripperOnce.Do(func() {
u.roundtripper = &badgateway.RoundTripper{
Socket: u.Socket,
ResponseHeaderTimeout: u.ResponseHeaderTimeout,
Socket: u.Socket,
ProxyHeadersTimeout: u.ProxyHeadersTimeout,
}
})
......
......@@ -14,7 +14,6 @@ In this file we start the web server and hand off to the upstream type.
package main
import (
"./internal/badgateway"
"./internal/upstream"
"flag"
"fmt"
......@@ -24,6 +23,7 @@ import (
_ "net/http/pprof"
"os"
"syscall"
"time"
)
// Current version of GitLab Workhorse
......@@ -37,7 +37,7 @@ var authBackend = URLFlag("authBackend", upstream.DefaultBackend, "Authenticatio
var authSocket = flag.String("authSocket", "", "Optional: Unix domain socket to dial authBackend at")
var pprofListenAddr = flag.String("pprofListenAddr", "", "pprof listening address, e.g. 'localhost:6060'")
var documentRoot = flag.String("documentRoot", "public", "Path to static files content")
var responseHeadersTimeout = flag.Duration("proxyHeadersTimeout", badgateway.DefaultTransport.ResponseHeaderTimeout, "How long to wait for response headers when proxying the request")
var proxyHeadersTimeout = flag.Duration("proxyHeadersTimeout", time.Minute, "How long to wait for response headers when proxying the request")
var developmentMode = flag.Bool("developmentMode", false, "Allow to serve assets from Rails app")
func main() {
......@@ -82,12 +82,12 @@ func main() {
}
up := &upstream.Upstream{
Backend: authBackend,
Socket: *authSocket,
Version: Version,
ResponseHeaderTimeout: *responseHeadersTimeout,
DocumentRoot: *documentRoot,
DevelopmentMode: *developmentMode,
Backend: authBackend,
Socket: *authSocket,
Version: Version,
ProxyHeadersTimeout: *proxyHeadersTimeout,
DocumentRoot: *documentRoot,
DevelopmentMode: *developmentMode,
}
log.Fatal(http.Serve(listener, up))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment