Skip to content

Commit ea29bea

Browse files
committed
backport DefaultReadHeaderTimeout from gokit
this is preparation for updating Go
1 parent 81db97f commit ea29bea

File tree

4 files changed

+20
-4
lines changed

4 files changed

+20
-4
lines changed

pkg/gokitbp/backports.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// `gokit` backports. things that exist in newer version of gokit, but which we cannot update to yet.
2+
package gokitbp
3+
4+
import (
5+
"time"
6+
)
7+
8+
var (
9+
DefaultReadHeaderTimeout = 60 * time.Second
10+
)

pkg/stofuse/restapi.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"github.com/function61/gokit/logex"
1010
"github.com/function61/gokit/taskrunner"
1111
"github.com/function61/pi-security-module/pkg/httpserver/muxregistrator"
12+
"github.com/function61/varasto/pkg/gokitbp"
1213
"github.com/function61/varasto/pkg/stofuse/stofusetypes"
1314
"github.com/function61/varasto/pkg/stoutils"
1415
"github.com/gorilla/mux"
@@ -35,7 +36,8 @@ func rpcStart(addr string, sigs *sigFabric, tasks *taskrunner.Runner) error {
3536
}
3637

3738
srv := &http.Server{
38-
Handler: router,
39+
Handler: router,
40+
ReadHeaderTimeout: gokitbp.DefaultReadHeaderTimeout,
3941
}
4042

4143
tasks.Start("rpc "+addr, func(_ context.Context) error {

pkg/stomediascanner/entrypoint.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"github.com/function61/gokit/logex"
1414
"github.com/function61/gokit/osutil"
1515
"github.com/function61/gokit/taskrunner"
16+
"github.com/function61/varasto/pkg/gokitbp"
1617
"github.com/function61/varasto/pkg/stoutils"
1718
"github.com/gorilla/mux"
1819
"github.com/spf13/cobra"
@@ -37,7 +38,8 @@ func logic(ctx context.Context, addr string, rootLogger *log.Logger) error {
3738
}
3839

3940
srv := &http.Server{
40-
Handler: router,
41+
Handler: router,
42+
ReadHeaderTimeout: gokitbp.DefaultReadHeaderTimeout,
4143
}
4244

4345
tasks := taskrunner.New(ctx, rootLogger)

pkg/stoserver/server.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import (
3131
"github.com/function61/varasto/pkg/blorm"
3232
"github.com/function61/varasto/pkg/childprocesscontroller"
3333
"github.com/function61/varasto/pkg/frontend"
34+
"github.com/function61/varasto/pkg/gokitbp"
3435
"github.com/function61/varasto/pkg/logtee"
3536
"github.com/function61/varasto/pkg/restartcontroller"
3637
"github.com/function61/varasto/pkg/scheduler"
@@ -226,8 +227,9 @@ func runServer(
226227
defineUI(router)
227228

228229
srv := &http.Server{
229-
Addr: "0.0.0.0:443", // 0.0.0.0 = listen on all interfaces
230-
Handler: serverConfig.Metrics.WrapHttpServer(router),
230+
Addr: "0.0.0.0:443", // 0.0.0.0 = listen on all interfaces
231+
Handler: serverConfig.Metrics.WrapHttpServer(router),
232+
ReadHeaderTimeout: gokitbp.DefaultReadHeaderTimeout,
231233
TLSConfig: &tls.Config{
232234
MinVersion: tls.VersionTLS12, // require TLS 1.2 minimum
233235
Certificates: []tls.Certificate{serverConfig.TlsCertificate.keypair},

0 commit comments

Comments
 (0)