diff options
Diffstat (limited to 'vendor/github.com/hashicorp/go-cleanhttp')
-rw-r--r-- | vendor/github.com/hashicorp/go-cleanhttp/cleanhttp.go | 1 | ||||
-rw-r--r-- | vendor/github.com/hashicorp/go-cleanhttp/go.mod | 1 | ||||
-rw-r--r-- | vendor/github.com/hashicorp/go-cleanhttp/handlers.go | 43 |
3 files changed, 45 insertions, 0 deletions
diff --git a/vendor/github.com/hashicorp/go-cleanhttp/cleanhttp.go b/vendor/github.com/hashicorp/go-cleanhttp/cleanhttp.go index 7d8a57c..8d306bf 100644 --- a/vendor/github.com/hashicorp/go-cleanhttp/cleanhttp.go +++ b/vendor/github.com/hashicorp/go-cleanhttp/cleanhttp.go | |||
@@ -26,6 +26,7 @@ func DefaultPooledTransport() *http.Transport { | |||
26 | DialContext: (&net.Dialer{ | 26 | DialContext: (&net.Dialer{ |
27 | Timeout: 30 * time.Second, | 27 | Timeout: 30 * time.Second, |
28 | KeepAlive: 30 * time.Second, | 28 | KeepAlive: 30 * time.Second, |
29 | DualStack: true, | ||
29 | }).DialContext, | 30 | }).DialContext, |
30 | MaxIdleConns: 100, | 31 | MaxIdleConns: 100, |
31 | IdleConnTimeout: 90 * time.Second, | 32 | IdleConnTimeout: 90 * time.Second, |
diff --git a/vendor/github.com/hashicorp/go-cleanhttp/go.mod b/vendor/github.com/hashicorp/go-cleanhttp/go.mod new file mode 100644 index 0000000..310f075 --- /dev/null +++ b/vendor/github.com/hashicorp/go-cleanhttp/go.mod | |||
@@ -0,0 +1 @@ | |||
module github.com/hashicorp/go-cleanhttp | |||
diff --git a/vendor/github.com/hashicorp/go-cleanhttp/handlers.go b/vendor/github.com/hashicorp/go-cleanhttp/handlers.go new file mode 100644 index 0000000..7eda377 --- /dev/null +++ b/vendor/github.com/hashicorp/go-cleanhttp/handlers.go | |||
@@ -0,0 +1,43 @@ | |||
1 | package cleanhttp | ||
2 | |||
3 | import ( | ||
4 | "net/http" | ||
5 | "strings" | ||
6 | "unicode" | ||
7 | ) | ||
8 | |||
9 | // HandlerInput provides input options to cleanhttp's handlers | ||
10 | type HandlerInput struct { | ||
11 | ErrStatus int | ||
12 | } | ||
13 | |||
14 | // PrintablePathCheckHandler is a middleware that ensures the request path | ||
15 | // contains only printable runes. | ||
16 | func PrintablePathCheckHandler(next http.Handler, input *HandlerInput) http.Handler { | ||
17 | // Nil-check on input to make it optional | ||
18 | if input == nil { | ||
19 | input = &HandlerInput{ | ||
20 | ErrStatus: http.StatusBadRequest, | ||
21 | } | ||
22 | } | ||
23 | |||
24 | // Default to http.StatusBadRequest on error | ||
25 | if input.ErrStatus == 0 { | ||
26 | input.ErrStatus = http.StatusBadRequest | ||
27 | } | ||
28 | |||
29 | return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { | ||
30 | // Check URL path for non-printable characters | ||
31 | idx := strings.IndexFunc(r.URL.Path, func(c rune) bool { | ||
32 | return !unicode.IsPrint(c) | ||
33 | }) | ||
34 | |||
35 | if idx != -1 { | ||
36 | w.WriteHeader(input.ErrStatus) | ||
37 | return | ||
38 | } | ||
39 | |||
40 | next.ServeHTTP(w, r) | ||
41 | return | ||
42 | }) | ||
43 | } | ||