Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions internal/handlers/blog.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}