✨ feat: add CloseResponseBodyGracefully function to handle HTTP response body closure
This commit is contained in:
13
common/http.go
Normal file
13
common/http.go
Normal file
@@ -0,0 +1,13 @@
|
||||
package common
|
||||
|
||||
import "net/http"
|
||||
|
||||
func CloseResponseBodyGracefully(httpResponse *http.Response) {
|
||||
if httpResponse == nil || httpResponse.Body == nil {
|
||||
return
|
||||
}
|
||||
err := httpResponse.Body.Close()
|
||||
if err != nil {
|
||||
SysError("failed to close response body: " + err.Error())
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user