mirror of
https://github.com/rclone/rclone.git
synced 2024-11-29 11:55:01 +01:00
serve http: error if Range supplied (not supported yet)
Also add Server header
This commit is contained in:
parent
2740c965c0
commit
cd146415d1
@ -46,6 +46,8 @@ The server will log errors. Use -v to see access logs.
|
||||
|
||||
--bwlimit will be respected for file transfers. Use --stats to
|
||||
control the stats printing.
|
||||
|
||||
Note the Range header is not supported yet.
|
||||
`,
|
||||
Run: func(command *cobra.Command, args []string) {
|
||||
cmd.CheckArgs(1, 1, command, args)
|
||||
@ -91,6 +93,15 @@ func (s *server) handler(w http.ResponseWriter, r *http.Request) {
|
||||
http.Error(w, "Method not allowed", http.StatusMethodNotAllowed)
|
||||
return
|
||||
}
|
||||
rangeHeader := r.Header.Get("Range")
|
||||
if rangeHeader != "" {
|
||||
http.Error(w, "Range not supported yet", http.StatusRequestedRangeNotSatisfiable)
|
||||
return
|
||||
}
|
||||
//r.Header().Set("Accept-Ranges", "bytes")
|
||||
w.Header().Set("Accept-Ranges", "none") // show we don't support Range yet
|
||||
w.Header().Set("Server", "rclone/"+fs.Version)
|
||||
|
||||
urlPath := r.URL.Path
|
||||
isDir := strings.HasSuffix(urlPath, "/")
|
||||
remote := strings.Trim(urlPath, "/")
|
||||
|
Loading…
Reference in New Issue
Block a user