Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions cmd/tusd/cli/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ var Flags struct {
HttpHooksBackoff time.Duration
HttpHooksTimeout time.Duration
HttpHooksSizeLimit int64
HttpHooksInsecure bool
GrpcHooksEndpoint string
GrpcHooksRetry int
GrpcHooksBackoff time.Duration
Expand Down Expand Up @@ -207,6 +208,7 @@ func ParseFlags() {
f.DurationVar(&Flags.HttpHooksBackoff, "hooks-http-backoff", 1*time.Second, "Wait period before retrying each retry")
f.DurationVar(&Flags.HttpHooksTimeout, "hooks-http-timeout", 15*time.Second, "Timeout for the HTTP hook requests")
f.Int64Var(&Flags.HttpHooksSizeLimit, "hooks-http-size-limit", 5*1024, "Maximum size of the response body in bytes")
f.BoolVar(&Flags.HttpHooksInsecure, "hooks-http-insecure", false, "Disables TLS verification for the HTTP hook requests")
})

fs.AddGroup("gRPC hook options", func(f *flag.FlagSet) {
Expand Down
1 change: 1 addition & 0 deletions cmd/tusd/cli/hooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ func getHookHandler(config *handler.Config) hooks.HookHandler {
ForwardHeaders: strings.Split(Flags.HttpHooksForwardHeaders, ","),
Timeout: Flags.HttpHooksTimeout,
SizeLimit: Flags.HttpHooksSizeLimit,
Insecure: Flags.HttpHooksInsecure,
}
} else if Flags.GrpcHooksEndpoint != "" {
printStartupLog("Using '%s' as the endpoint for gRPC hooks", Flags.GrpcHooksEndpoint)
Expand Down
22 changes: 22 additions & 0 deletions pkg/hooks/http/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ package http
import (
"bytes"
"context"
"crypto/tls"
"encoding/json"
"fmt"
"io"
"mime"
"net"
"net/http"
"time"

Expand All @@ -25,6 +27,7 @@ type HttpHook struct {
ForwardHeaders []string
Timeout time.Duration
SizeLimit int64
Insecure bool

client *pester.Client
}
Expand All @@ -37,6 +40,25 @@ func (h *HttpHook) Setup() error {
client.Backoff = func(_ int) time.Duration {
return h.Backoff
}
// The transport uses the same values as the http.DefaultTransport.
t := &http.Transport{
Proxy: http.ProxyFromEnvironment,
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,
}
if h.Insecure {
t.TLSClientConfig = &tls.Config{
InsecureSkipVerify: true,
}
}
client.Transport = t

h.client = client

Expand Down