Skip to content

Commit 707dc37

Browse files
lpcoxCopilot
andauthored
Update internal/httputil/httputil.go
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 60fe5a8 commit 707dc37

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

internal/httputil/httputil.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,14 @@ func WriteJSONResponse(w http.ResponseWriter, statusCode int, body interface{})
2626
return
2727
}
2828
logHTTP.Printf("JSON response body size: %d bytes", len(data))
29-
w.Write(data)
29+
n, err := w.Write(data)
30+
if err != nil {
31+
logHTTP.Printf("Failed to write JSON response body: wrote=%d expected=%d err=%v", n, len(data), err)
32+
return
33+
}
34+
if n != len(data) {
35+
logHTTP.Printf("Short write for JSON response body: wrote=%d expected=%d", n, len(data))
36+
}
3037
}
3138

3239
// ParseRateLimitResetHeader parses the Unix-timestamp value of the

0 commit comments

Comments
 (0)