librclone: allow empty string or null input instead of empty json object

This commit is contained in:
albertony 2021-10-24 17:35:13 +02:00 committed by Nick Craig-Wood
parent be1a668e95
commit fd82876086
1 changed files with 5 additions and 3 deletions

View File

@ -88,9 +88,11 @@ func RPC(method string, input string) (output string, status int) {
}()
// create a buffer to capture the output
err := json.NewDecoder(strings.NewReader(input)).Decode(&in)
if err != nil {
return writeError(method, in, fmt.Errorf("failed to read input JSON: %w", err), http.StatusBadRequest)
if input != "" {
err := json.NewDecoder(strings.NewReader(input)).Decode(&in)
if err != nil {
return writeError(method, in, fmt.Errorf("failed to read input JSON: %w", err), http.StatusBadRequest)
}
}
// Find the call