diff --git a/cmd/serve/http/http.go b/cmd/serve/http/http.go index 95c764350..80972db96 100644 --- a/cmd/serve/http/http.go +++ b/cmd/serve/http/http.go @@ -9,7 +9,6 @@ import ( "path" "strconv" "strings" - "time" "github.com/ncw/rclone/cmd" "github.com/ncw/rclone/fs" @@ -77,12 +76,11 @@ func (s *server) serve() { mux.HandleFunc("/", s.handler) // FIXME make a transport? httpServer := &http.Server{ - Addr: s.bindAddress, - Handler: mux, - ReadHeaderTimeout: 10 * time.Second, // time to send the headers - IdleTimeout: 60 * time.Second, // time to keep idle connections open - MaxHeaderBytes: 1 << 20, + Addr: s.bindAddress, + Handler: mux, + MaxHeaderBytes: 1 << 20, } + initServer(httpServer) fs.Logf(s.f, "Serving on http://%s/", bindAddress) log.Fatal(httpServer.ListenAndServe()) } diff --git a/cmd/serve/http/http_new.go b/cmd/serve/http/http_new.go new file mode 100644 index 000000000..8b15933f1 --- /dev/null +++ b/cmd/serve/http/http_new.go @@ -0,0 +1,16 @@ +// HTTP parts go1.8+ + +//+build go1.8 + +package http + +import ( + "net/http" + "time" +) + +// Initialise the http.Server for pre go1.8 +func initServer(s *http.Server) { + s.ReadHeaderTimeout = 10 * time.Second // time to send the headers + s.IdleTimeout = 60 * time.Second // time to keep idle connections open +} diff --git a/cmd/serve/http/http_old.go b/cmd/serve/http/http_old.go new file mode 100644 index 000000000..92f570392 --- /dev/null +++ b/cmd/serve/http/http_old.go @@ -0,0 +1,13 @@ +// HTTP parts pre go1.8 + +//+build !go1.8 + +package http + +import ( + "net/http" +) + +// Initialise the http.Server for pre go1.8 +func initServer(s *http.Server) { +}