Commit db0dc783 authored by Jacob Vosmaer's avatar Jacob Vosmaer

Hide ResponseHeaderTimeout

parent 6951b3e4
...@@ -18,15 +18,14 @@ var DefaultDialer = &net.Dialer{ ...@@ -18,15 +18,14 @@ var DefaultDialer = &net.Dialer{
} }
var DefaultTransport = &http.Transport{ var DefaultTransport = &http.Transport{
Proxy: http.ProxyFromEnvironment, // from http.DefaultTransport Proxy: http.ProxyFromEnvironment, // from http.DefaultTransport
Dial: DefaultDialer.Dial, // from http.DefaultTransport Dial: DefaultDialer.Dial, // from http.DefaultTransport
ResponseHeaderTimeout: time.Minute, // custom TLSHandshakeTimeout: 10 * time.Second, // from http.DefaultTransport
TLSHandshakeTimeout: 10 * time.Second, // from http.DefaultTransport
} }
type RoundTripper struct { type RoundTripper struct {
Socket string Socket string
ResponseHeaderTimeout time.Duration ProxyHeadersTimeout time.Duration
Transport *http.Transport Transport *http.Transport
configureRoundTripperOnce sync.Once configureRoundTripperOnce sync.Once
} }
...@@ -69,10 +68,7 @@ func (t *RoundTripper) configureRoundTripper() { ...@@ -69,10 +68,7 @@ func (t *RoundTripper) configureRoundTripper() {
} }
tr := *DefaultTransport tr := *DefaultTransport
tr.ResponseHeaderTimeout = t.ProxyHeadersTimeout
if t.ResponseHeaderTimeout != 0 {
tr.ResponseHeaderTimeout = t.ResponseHeaderTimeout
}
if t.Socket != "" { if t.Socket != "" {
tr.Dial = func(_, _ string) (net.Conn, error) { tr.Dial = func(_, _ string) (net.Conn, error) {
......
...@@ -21,12 +21,12 @@ import ( ...@@ -21,12 +21,12 @@ import (
var DefaultBackend = helper.URLMustParse("http://localhost:8080") var DefaultBackend = helper.URLMustParse("http://localhost:8080")
type Upstream struct { type Upstream struct {
Backend *url.URL Backend *url.URL
Version string Version string
Socket string Socket string
DocumentRoot string DocumentRoot string
DevelopmentMode bool DevelopmentMode bool
ResponseHeaderTimeout time.Duration ProxyHeadersTimeout time.Duration
urlPrefix urlprefix.Prefix urlPrefix urlprefix.Prefix
configureURLPrefixOnce sync.Once configureURLPrefixOnce sync.Once
...@@ -56,8 +56,8 @@ func (u *Upstream) URLPrefix() urlprefix.Prefix { ...@@ -56,8 +56,8 @@ func (u *Upstream) URLPrefix() urlprefix.Prefix {
func (u *Upstream) RoundTripper() *badgateway.RoundTripper { func (u *Upstream) RoundTripper() *badgateway.RoundTripper {
u.configureRoundTripperOnce.Do(func() { u.configureRoundTripperOnce.Do(func() {
u.roundtripper = &badgateway.RoundTripper{ u.roundtripper = &badgateway.RoundTripper{
Socket: u.Socket, Socket: u.Socket,
ResponseHeaderTimeout: u.ResponseHeaderTimeout, ProxyHeadersTimeout: u.ProxyHeadersTimeout,
} }
}) })
......
...@@ -14,7 +14,6 @@ In this file we start the web server and hand off to the upstream type. ...@@ -14,7 +14,6 @@ In this file we start the web server and hand off to the upstream type.
package main package main
import ( import (
"./internal/badgateway"
"./internal/upstream" "./internal/upstream"
"flag" "flag"
"fmt" "fmt"
...@@ -24,6 +23,7 @@ import ( ...@@ -24,6 +23,7 @@ import (
_ "net/http/pprof" _ "net/http/pprof"
"os" "os"
"syscall" "syscall"
"time"
) )
// Current version of GitLab Workhorse // Current version of GitLab Workhorse
...@@ -37,7 +37,7 @@ var authBackend = URLFlag("authBackend", upstream.DefaultBackend, "Authenticatio ...@@ -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 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 pprofListenAddr = flag.String("pprofListenAddr", "", "pprof listening address, e.g. 'localhost:6060'")
var documentRoot = flag.String("documentRoot", "public", "Path to static files content") 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") var developmentMode = flag.Bool("developmentMode", false, "Allow to serve assets from Rails app")
func main() { func main() {
...@@ -82,12 +82,12 @@ func main() { ...@@ -82,12 +82,12 @@ func main() {
} }
up := &upstream.Upstream{ up := &upstream.Upstream{
Backend: authBackend, Backend: authBackend,
Socket: *authSocket, Socket: *authSocket,
Version: Version, Version: Version,
ResponseHeaderTimeout: *responseHeadersTimeout, ProxyHeadersTimeout: *proxyHeadersTimeout,
DocumentRoot: *documentRoot, DocumentRoot: *documentRoot,
DevelopmentMode: *developmentMode, DevelopmentMode: *developmentMode,
} }
log.Fatal(http.Serve(listener, up)) 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