From fdf608904dc45ec323b77d71dcccdbedba7f7f51 Mon Sep 17 00:00:00 2001 From: Andrey Meshkov Date: Fri, 10 Jul 2020 22:20:30 +0300 Subject: [PATCH] Fix version check when req body is empty --- home/control_update.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/home/control_update.go b/home/control_update.go index 80ade843..d734f4d1 100644 --- a/home/control_update.go +++ b/home/control_update.go @@ -45,10 +45,13 @@ func handleGetVersionJSON(w http.ResponseWriter, r *http.Request) { } req := getVersionJSONRequest{} - err := json.NewDecoder(r.Body).Decode(&req) - if err != nil { - httpError(w, http.StatusBadRequest, "JSON parse: %s", err) - return + var err error + if r.ContentLength != 0 { + err = json.NewDecoder(r.Body).Decode(&req) + if err != nil { + httpError(w, http.StatusBadRequest, "JSON parse: %s", err) + return + } } now := time.Now()