From c550a886e94b5596a093cedd606dffd4199a93e2 Mon Sep 17 00:00:00 2001 From: Tony Chen Date: Thu, 17 Mar 2022 10:04:48 +0800 Subject: [PATCH] fix: decode empty body (#1882) --- transport/http/codec.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/transport/http/codec.go b/transport/http/codec.go index ef00ea6e9..bda318398 100644 --- a/transport/http/codec.go +++ b/transport/http/codec.go @@ -31,6 +31,9 @@ func DefaultRequestDecoder(r *http.Request, v interface{}) error { if err != nil { return errors.BadRequest("CODEC", err.Error()) } + if len(data) == 0 { + return nil + } if err = codec.Unmarshal(data, v); err != nil { return errors.BadRequest("CODEC", err.Error()) }