diff options
| author | Matthew Holt <mholt@users.noreply.github.com> | 2019-10-05 16:22:05 -0600 | 
|---|---|---|
| committer | Matthew Holt <mholt@users.noreply.github.com> | 2019-10-05 16:22:05 -0600 | 
| commit | be7abda7d498272e360fe6fae18984c309533de3 (patch) | |
| tree | de44cca3d4bece45fd8cce01b1e513fe99f46374 /modules/caddyhttp/reverseproxy/httptransport.go | |
| parent | 6fd28b81dcfa41ea84e376d569d90a08e172e263 (diff) | |
reverse_proxy: Implement retry_match; by default only retry GET requests
See https://caddy.community/t/http-proxy-and-non-get-retries/6304
Diffstat (limited to 'modules/caddyhttp/reverseproxy/httptransport.go')
| -rw-r--r-- | modules/caddyhttp/reverseproxy/httptransport.go | 9 | 
1 files changed, 8 insertions, 1 deletions
diff --git a/modules/caddyhttp/reverseproxy/httptransport.go b/modules/caddyhttp/reverseproxy/httptransport.go index 00b58a4..4ff9989 100644 --- a/modules/caddyhttp/reverseproxy/httptransport.go +++ b/modules/caddyhttp/reverseproxy/httptransport.go @@ -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),  | 
