Skip to content

Commit 737c953

Browse files
committed
Close req body in http mode
Request body should be closed in http mode to prevent any dangling connections. Signed-off-by: Alex Ellis (VMware) <[email protected]>
1 parent 7805183 commit 737c953

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

executor/http_runner.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ func (f *HTTPFunctionRunner) Run(req FunctionRequest, contentLength int64, r *ht
148148
w.WriteHeader(res.StatusCode)
149149
if res.Body != nil {
150150
defer res.Body.Close()
151+
151152
bodyBytes, bodyErr := ioutil.ReadAll(res.Body)
152153
if bodyErr != nil {
153154
log.Println("read body err", bodyErr)

main.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,10 @@ func makeHTTPRequestHandler(watchdogConfig config.WatchdogConfig) func(http.Resp
214214
OutputWriter: w,
215215
}
216216

217+
if r.Body != nil {
218+
defer r.Body.Close()
219+
}
220+
217221
err := functionInvoker.Run(req, r.ContentLength, r, w)
218222

219223
if err != nil {

0 commit comments

Comments
 (0)