Send 'Retry-After' to comply with RFC6585.
This commit is contained in:
parent
027093a5a5
commit
8d75aba7eb
29 changed files with 435 additions and 172 deletions
24
vendor/github.com/vulcand/oxy/forward/fwd.go
generated
vendored
24
vendor/github.com/vulcand/oxy/forward/fwd.go
generated
vendored
|
@ -1,4 +1,4 @@
|
|||
// package forwarder implements http handler that forwards requests to remote server
|
||||
// Package forward implements http handler that forwards requests to remote server
|
||||
// and serves back the response
|
||||
// websocket proxying support based on https://github.com/yhat/wsutil
|
||||
package forward
|
||||
|
@ -21,7 +21,7 @@ import (
|
|||
"github.com/vulcand/oxy/utils"
|
||||
)
|
||||
|
||||
// Oxy Logger interface of the internal
|
||||
// OxyLogger interface of the internal
|
||||
type OxyLogger interface {
|
||||
log.FieldLogger
|
||||
GetLevel() log.Level
|
||||
|
@ -42,8 +42,7 @@ type ReqRewriter interface {
|
|||
|
||||
type optSetter func(f *Forwarder) error
|
||||
|
||||
// PassHostHeader specifies if a client's Host header field should
|
||||
// be delegated
|
||||
// PassHostHeader specifies if a client's Host header field should be delegated
|
||||
func PassHostHeader(b bool) optSetter {
|
||||
return func(f *Forwarder) error {
|
||||
f.httpForwarder.passHost = b
|
||||
|
@ -68,8 +67,7 @@ func Rewriter(r ReqRewriter) optSetter {
|
|||
}
|
||||
}
|
||||
|
||||
// PassHostHeader specifies if a client's Host header field should
|
||||
// be delegated
|
||||
// WebsocketTLSClientConfig define the websocker client TLS configuration
|
||||
func WebsocketTLSClientConfig(tcc *tls.Config) optSetter {
|
||||
return func(f *Forwarder) error {
|
||||
f.httpForwarder.tlsClientConfig = tcc
|
||||
|
@ -120,6 +118,7 @@ func Logger(l log.FieldLogger) optSetter {
|
|||
}
|
||||
}
|
||||
|
||||
// StateListener defines a state listener for the HTTP forwarder
|
||||
func StateListener(stateListener UrlForwardingStateListener) optSetter {
|
||||
return func(f *Forwarder) error {
|
||||
f.stateListener = stateListener
|
||||
|
@ -127,6 +126,7 @@ func StateListener(stateListener UrlForwardingStateListener) optSetter {
|
|||
}
|
||||
}
|
||||
|
||||
// ResponseModifier defines a response modifier for the HTTP forwarder
|
||||
func ResponseModifier(responseModifier func(*http.Response) error) optSetter {
|
||||
return func(f *Forwarder) error {
|
||||
f.httpForwarder.modifyResponse = responseModifier
|
||||
|
@ -134,6 +134,7 @@ func ResponseModifier(responseModifier func(*http.Response) error) optSetter {
|
|||
}
|
||||
}
|
||||
|
||||
// StreamingFlushInterval defines a streaming flush interval for the HTTP forwarder
|
||||
func StreamingFlushInterval(flushInterval time.Duration) optSetter {
|
||||
return func(f *Forwarder) error {
|
||||
f.httpForwarder.flushInterval = flushInterval
|
||||
|
@ -141,11 +142,13 @@ func StreamingFlushInterval(flushInterval time.Duration) optSetter {
|
|||
}
|
||||
}
|
||||
|
||||
// ErrorHandlingRoundTripper a error handling round tripper
|
||||
type ErrorHandlingRoundTripper struct {
|
||||
http.RoundTripper
|
||||
errorHandler utils.ErrorHandler
|
||||
}
|
||||
|
||||
// RoundTrip executes the round trip
|
||||
func (rt ErrorHandlingRoundTripper) RoundTrip(req *http.Request) (*http.Response, error) {
|
||||
res, err := rt.RoundTripper.RoundTrip(req)
|
||||
if err != nil {
|
||||
|
@ -188,12 +191,15 @@ type httpForwarder struct {
|
|||
bufferPool httputil.BufferPool
|
||||
}
|
||||
|
||||
const defaultFlushInterval = time.Duration(100) * time.Millisecond
|
||||
|
||||
// Connection states
|
||||
const (
|
||||
defaultFlushInterval = time.Duration(100) * time.Millisecond
|
||||
StateConnected = iota
|
||||
StateConnected = iota
|
||||
StateDisconnected
|
||||
)
|
||||
|
||||
// UrlForwardingStateListener URL forwarding state listener
|
||||
type UrlForwardingStateListener func(*url.URL, int)
|
||||
|
||||
// New creates an instance of Forwarder based on the provided list of configuration options
|
||||
|
@ -501,7 +507,7 @@ func (f *httpForwarder) serveHTTP(w http.ResponseWriter, inReq *http.Request, ct
|
|||
}
|
||||
}
|
||||
|
||||
// isWebsocketRequest determines if the specified HTTP request is a
|
||||
// IsWebsocketRequest determines if the specified HTTP request is a
|
||||
// websocket handshake request
|
||||
func IsWebsocketRequest(req *http.Request) bool {
|
||||
containsHeader := func(name, value string) bool {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue