✨ feat: add CloseResponseBodyGracefully function to handle HTTP response body closure
This commit is contained in:
1 parent
7ef4531a0f
commit
ae586e1be9
23 files changed
+52
-125
No files matched your search
@@ -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