mirror of
https://github.com/kemko/reproxy.git
synced 2026-01-04 09:15:50 +03:00
don't use default transport for proxy, causing race with tests
This commit is contained in:
@@ -53,7 +53,7 @@ func TestHttp_healthHandler(t *testing.T) {
|
||||
go func() {
|
||||
_ = h.Run(ctx)
|
||||
}()
|
||||
time.Sleep(10 * time.Millisecond)
|
||||
time.Sleep(20 * time.Millisecond)
|
||||
|
||||
client := http.Client{}
|
||||
req, err := http.NewRequest("GET", "http://127.0.0.1:"+strconv.Itoa(port)+"/health", nil)
|
||||
|
||||
@@ -141,8 +141,18 @@ func (h *Http) proxyHandler() http.HandlerFunc {
|
||||
},
|
||||
}
|
||||
|
||||
reverseProxy.Transport = http.DefaultTransport
|
||||
reverseProxy.Transport.(*http.Transport).ResponseHeaderTimeout = h.TimeOut
|
||||
reverseProxy.Transport = &http.Transport{
|
||||
ResponseHeaderTimeout: h.TimeOut,
|
||||
DialContext: (&net.Dialer{
|
||||
Timeout: 30 * time.Second,
|
||||
KeepAlive: 30 * time.Second,
|
||||
}).DialContext,
|
||||
ForceAttemptHTTP2: true,
|
||||
MaxIdleConns: 100,
|
||||
IdleConnTimeout: 90 * time.Second,
|
||||
TLSHandshakeTimeout: 10 * time.Second,
|
||||
ExpectContinueTimeout: 1 * time.Second,
|
||||
}
|
||||
|
||||
// default assetsHandler disabled, returns error on missing matches
|
||||
assetsHandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
@@ -42,6 +42,7 @@ func TestHttp_Do(t *testing.T) {
|
||||
_ = svc.Run(context.Background())
|
||||
}()
|
||||
|
||||
time.Sleep(10 * time.Millisecond)
|
||||
h.Matcher = svc
|
||||
go func() {
|
||||
_ = h.Run(ctx)
|
||||
@@ -113,7 +114,7 @@ func TestHttp_DoWithAssets(t *testing.T) {
|
||||
go func() {
|
||||
_ = svc.Run(context.Background())
|
||||
}()
|
||||
|
||||
time.Sleep(10 * time.Millisecond)
|
||||
h.Matcher = svc
|
||||
go func() {
|
||||
_ = h.Run(ctx)
|
||||
|
||||
Reference in New Issue
Block a user