diff --git a/internal/handlers/blog.go b/internal/handlers/blog.go index 160804a..9df1770 100644 --- a/internal/handlers/blog.go +++ b/internal/handlers/blog.go @@ -161,10 +161,17 @@ func (h *BlogHandler) Feed(w http.ResponseWriter, r *http.Request) { data, err := xml.MarshalIndent(feed, "", " ") if err != nil { - http.Error(w, err.Error(), http.StatusInternalServerError) + http.Error(w, "Internal Server Error", http.StatusInternalServerError) return } - w.Write([]byte(xml.Header)) - w.Write(data) + // Combine header and data into a single write to avoid partial writes + output := make([]byte, 0, len(xml.Header)+len(data)) + output = append(output, []byte(xml.Header)...) + output = append(output, data...) + if _, err := w.Write(output); err != nil { + // Cannot send error response after w.Write has been called + // Log the error if needed + return + } }