From d264a2cf0a4704aca0ab787eb9eccda647015633 Mon Sep 17 00:00:00 2001 From: Matthew Holt Date: Tue, 24 Jan 2017 20:09:03 -0700 Subject: [PATCH] Set Go 1.8's ReadHeaderTimeout and IdleTimeout --- caddyhttp/httpserver/server.go | 5 ++--- caddyhttp/httpserver/server_test.go | 13 ++++++------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/caddyhttp/httpserver/server.go b/caddyhttp/httpserver/server.go index 3bd3593e3..8dace1ee3 100644 --- a/caddyhttp/httpserver/server.go +++ b/caddyhttp/httpserver/server.go @@ -394,11 +394,10 @@ func makeHTTPServer(addr string, group []*SiteConfig) *http.Server { } // set the final values on the server - // TODO: ReadHeaderTimeout and IdleTimeout require Go 1.8 s.ReadTimeout = min.ReadTimeout - // s.ReadHeaderTimeout = min.ReadHeaderTimeout + s.ReadHeaderTimeout = min.ReadHeaderTimeout s.WriteTimeout = min.WriteTimeout - // s.IdleTimeout = min.IdleTimeout + s.IdleTimeout = min.IdleTimeout return s } diff --git a/caddyhttp/httpserver/server_test.go b/caddyhttp/httpserver/server_test.go index 46b53925a..dc926c596 100644 --- a/caddyhttp/httpserver/server_test.go +++ b/caddyhttp/httpserver/server_test.go @@ -100,15 +100,14 @@ func TestMakeHTTPServer(t *testing.T) { if got, want := actual.ReadTimeout, tc.expected.ReadTimeout; got != want { t.Errorf("Test %d: Expected ReadTimeout=%v, but was %v", i, want, got) } - // TODO: ReadHeaderTimeout and IdleTimeout require Go 1.8 - // if got, want := actual.ReadHeaderTimeout, tc.expected.ReadHeaderTimeout; got != want { - // t.Errorf("Test %d: Expected ReadHeaderTimeout=%v, but was %v", i, want, got) - // } + if got, want := actual.ReadHeaderTimeout, tc.expected.ReadHeaderTimeout; got != want { + t.Errorf("Test %d: Expected ReadHeaderTimeout=%v, but was %v", i, want, got) + } if got, want := actual.WriteTimeout, tc.expected.WriteTimeout; got != want { t.Errorf("Test %d: Expected WriteTimeout=%v, but was %v", i, want, got) } - // if got, want := actual.IdleTimeout, tc.expected.IdleTimeout; got != want { - // t.Errorf("Test %d: Expected IdleTimeout=%v, but was %v", i, want, got) - // } + if got, want := actual.IdleTimeout, tc.expected.IdleTimeout; got != want { + t.Errorf("Test %d: Expected IdleTimeout=%v, but was %v", i, want, got) + } } }