reverse_proxy: Implement retry_match; by default only retry GET requests

See https://caddy.community/t/http-proxy-and-non-get-retries/6304
This commit is contained in:
Matthew Holt
2019-10-05 16:22:05 -06:00
parent 6fd28b81dc
commit be7abda7d4
2 changed files with 58 additions and 20 deletions

View File

@@ -79,7 +79,14 @@ func (h *HTTPTransport) Provision(_ caddy.Context) error {
network = dialInfo.Network
address = dialInfo.Address
}
return dialer.DialContext(ctx, network, address)
conn, err := dialer.DialContext(ctx, network, address)
if err != nil {
// identify this error as one that occurred during
// dialing, which can be important when trying to
// decide whether to retry a request
return nil, DialError{err}
}
return conn, nil
},
MaxConnsPerHost: h.MaxConnsPerHost,
ResponseHeaderTimeout: time.Duration(h.ResponseHeaderTimeout),