mirror of
https://github.com/rclone/rclone.git
synced 2024-11-22 16:34:30 +01:00
serve restic: only accept v2 API requests for list
This commit is contained in:
parent
43c7ea81df
commit
4e90ad04d5
@ -143,6 +143,10 @@ these **must** end with /. Eg
|
||||
},
|
||||
}
|
||||
|
||||
const (
|
||||
resticAPIV2 = "application/vnd.x.restic.rest.v2"
|
||||
)
|
||||
|
||||
// server contains everything to run the server
|
||||
type server struct {
|
||||
f fs.Fs
|
||||
@ -362,6 +366,12 @@ func (ls *listItems) add(entry fs.DirEntry) {
|
||||
func (s *server) listObjects(w http.ResponseWriter, r *http.Request, remote string) {
|
||||
fs.Debugf(remote, "list request")
|
||||
|
||||
if r.Header.Get("Accept") != resticAPIV2 {
|
||||
fs.Errorf(remote, "Restic v2 API required")
|
||||
http.Error(w, "Restic v2 API required", http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
// make sure an empty list is returned, and not a 'nil' value
|
||||
ls := listItems{}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user