serve http: make it compile on go1.6 and go1.7

This commit is contained in:
Nick Craig-Wood 2017-10-26 21:52:29 +01:00
parent 39b9f80302
commit 96665c16cb
3 changed files with 33 additions and 6 deletions

View File

@ -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())
}

View File

@ -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
}

View File

@ -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) {
}