File tree Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -88,6 +88,9 @@ func GetBody(req *http.Request) ([]byte, error) {
8888
8989 if err != nil {
9090 log .Error ("Could not read Body: " , err .Error ())
91+
92+ req .Body .Close ()
93+
9194 return nil , err
9295 }
9396 defer req .Body .Close ()
@@ -97,14 +100,20 @@ func GetBody(req *http.Request) ([]byte, error) {
97100
98101func GetReqBody (w http.ResponseWriter , req * http.Request ) Body {
99102 bytes , err := GetBody (req )
103+
104+ var isEmpty bool
105+
106+ isEmpty = len (bytes ) > 0
107+
108+ if isEmpty {
109+ return Body {Empty : true }
110+ }
100111
101112 if err != nil {
102113 http .Error (w , "Internal Server Error" , http .StatusInternalServerError )
103- req .Body .Close ()
104114
105115 return Body {Empty : true }
106116 }
107- defer req .Body .Close ()
108117
109118 var data map [string ]interface {}
110119
@@ -123,7 +132,7 @@ func GetReqBody(w http.ResponseWriter, req *http.Request) Body {
123132 }
124133 }
125134
126- isEmpty : = len (data ) <= 0
135+ isEmpty = len (data ) <= 0
127136
128137 return Body {
129138 Raw : bytes ,
You can’t perform that action at this time.
0 commit comments