mirror of
https://github.com/rclone/rclone.git
synced 2024-11-22 16:34:30 +01:00
serve http: make it compile on go1.6 and go1.7
This commit is contained in:
parent
39b9f80302
commit
96665c16cb
@ -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())
|
||||
}
|
||||
|
16
cmd/serve/http/http_new.go
Normal file
16
cmd/serve/http/http_new.go
Normal 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
|
||||
}
|
13
cmd/serve/http/http_old.go
Normal file
13
cmd/serve/http/http_old.go
Normal 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) {
|
||||
}
|
Loading…
Reference in New Issue
Block a user