mirror of
https://github.com/1f349/violet.git
synced 2024-11-09 22:22:50 +00:00
Close RoundTrip response body with defer
This commit is contained in:
parent
3141b3bc55
commit
78d930d32c
@ -170,6 +170,12 @@ func (r Route) internalServeHTTP(rw http.ResponseWriter, req *http.Request) {
|
|||||||
utils.RespondVioletError(rw, http.StatusBadGateway, "error receiving internal round trip response")
|
utils.RespondVioletError(rw, http.StatusBadGateway, "error receiving internal round trip response")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// make sure to close response body after use
|
||||||
|
if resp.Body != nil {
|
||||||
|
defer resp.Body.Close()
|
||||||
|
}
|
||||||
|
|
||||||
if resp.StatusCode == http.StatusLoopDetected {
|
if resp.StatusCode == http.StatusLoopDetected {
|
||||||
u := uuid.New()
|
u := uuid.New()
|
||||||
log.Printf("[ServeRoute::ServeHTTP()] Loop Detected: %s %s '%s' -> '%s'\n", u, req.Method, req.URL.String(), req2.URL.String())
|
log.Printf("[ServeRoute::ServeHTTP()] Loop Detected: %s %s '%s' -> '%s'\n", u, req.Method, req.URL.String(), req2.URL.String())
|
||||||
|
Loading…
Reference in New Issue
Block a user